27 DLOG(
"Ungrabbing all keys\n");
28 xcb_ungrab_key(conn, XCB_GRAB_ANY,
root, XCB_BUTTON_MASK_ANY);
32 DLOG(
"Grabbing %d\n", keycode);
34 #define GRAB_KEY(modifier) \
36 xcb_grab_key(conn, 0, root, modifier, keycode, \
37 XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC); \
39 int mods = bind->
mods;
43 mods = XCB_MOD_MASK_ANY;
60 if (bind->
mods != modifiers)
65 if (bind->
symbol != NULL) {
68 &keycode,
sizeof(xcb_keycode_t)) != NULL)
89 min_keycode = xcb_get_setup(
conn)->min_keycode,
90 max_keycode = xcb_get_setup(
conn)->max_keycode;
97 keysym = XStringToKeysym(bind->
symbol);
98 if (keysym == NoSymbol) {
99 ELOG(
"Could not translate string to key symbol: \"%s\"\n",
113 for (i = min_keycode; i && i <= max_keycode; i++) {
114 if ((xcb_key_symbols_get_keysym(
keysyms, i, col) != keysym) &&
115 (xcb_key_symbols_get_keysym(
keysyms, i, col+1) != keysym))
119 (
sizeof(xcb_keycode_t) *
124 DLOG(
"Translated symbol \"%s\" to %d keycode\n", bind->
symbol,
159 LOG(
"Switching to mode %s\n", new_mode);
162 if (strcasecmp(mode->
name, new_mode) != 0)
172 ELOG(
"ERROR: Mode not found\n");
184 char *xdg_config_home, *xdg_config_dirs, *config_path;
186 static const char *saved_configpath = NULL;
188 if (override_configpath != NULL) {
189 saved_configpath = override_configpath;
190 return sstrdup(saved_configpath);
193 if (saved_configpath != NULL)
194 return sstrdup(saved_configpath);
203 if ((xdg_config_home = getenv(
"XDG_CONFIG_HOME")) == NULL)
204 xdg_config_home =
"~/.config";
207 sasprintf(&config_path,
"%s/i3/config", xdg_config_home);
208 free(xdg_config_home);
215 config_path = SYSCONFDIR
"/i3/config";
220 if ((xdg_config_dirs = getenv(
"XDG_CONFIG_DIRS")) == NULL)
221 xdg_config_dirs =
"/etc/xdg";
223 char *buf =
sstrdup(xdg_config_dirs);
224 char *tok = strtok(buf,
":");
225 while (tok != NULL) {
227 sasprintf(&config_path,
"%s/i3/config", tok);
234 tok = strtok(NULL,
":");
238 die(
"Unable to find the configuration file (looked at "
239 "~/.i3/config, $XDG_CONFIG_HOME/i3/config, "
240 SYSCONFDIR
"/i3/config and $XDG_CONFIG_DIRS/i3/config)");
251 LOG(
"Parsing configfile %s\n", path);
334 workspace_set_name(ws, NULL);
356 #define REQUIRED_OPTION(name) \
357 if (config.name == NULL) \
358 die("You did not specify required configuration option " #name "\n");
361 memset(&config, 0,
sizeof(config));
364 #define INIT_COLOR(x, cborder, cbackground, ctext, cindicator) \
366 x.border = get_colorpixel(cborder); \
367 x.background = get_colorpixel(cbackground); \
368 x.text = get_colorpixel(ctext); \
369 x.indicator = get_colorpixel(cindicator); \
395 if (config.
font.
id == 0) {
396 ELOG(
"You did not specify required configuration option \"font\"\n");
412 if (ws->name != NULL) {
415 if (ws->text_width == 0)
417 config.
font, ws->name, ws->name_len);
421 workspace_set_name(ws, NULL);