2 #define I3__FILE__ "config.c"
29 DLOG(
"Ungrabbing all keys\n");
30 xcb_ungrab_key(conn, XCB_GRAB_ANY,
root, XCB_BUTTON_MASK_ANY);
34 DLOG(
"Grabbing %d\n", keycode);
36 #define GRAB_KEY(modifier) \
38 xcb_grab_key(conn, 0, root, modifier, keycode, \
39 XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC); \
41 int mods = bind->
mods;
45 mods = XCB_MOD_MASK_ANY;
65 if (bind->
release == B_UPON_KEYRELEASE_IGNORE_MODS)
66 bind->
release = B_UPON_KEYRELEASE;
73 if (bind->
release == B_UPON_KEYRELEASE && !key_release)
74 bind->
release = B_UPON_KEYRELEASE_IGNORE_MODS;
82 if (bind->
mods != modifiers &&
83 (bind->
release != B_UPON_KEYRELEASE_IGNORE_MODS ||
88 if ((bind->
release == B_UPON_KEYPRESS && key_release) ||
89 (bind->
release >= B_UPON_KEYRELEASE && !key_release))
94 if (bind->
symbol != NULL) {
97 &keycode,
sizeof(xcb_keycode_t)) != NULL)
118 min_keycode = xcb_get_setup(
conn)->min_keycode,
119 max_keycode = xcb_get_setup(
conn)->max_keycode;
126 keysym = XStringToKeysym(bind->
symbol);
127 if (keysym == NoSymbol) {
128 ELOG(
"Could not translate string to key symbol: \"%s\"\n",
142 for (i = min_keycode; i && i <= max_keycode; i++) {
143 if ((xcb_key_symbols_get_keysym(
keysyms, i, col) != keysym) &&
144 (xcb_key_symbols_get_keysym(
keysyms, i, col+1) != keysym))
148 (
sizeof(xcb_keycode_t) *
153 DLOG(
"Translated symbol \"%s\" to %d keycode\n", bind->
symbol,
188 LOG(
"Switching to mode %s\n", new_mode);
191 if (strcasecmp(mode->
name, new_mode) != 0)
208 ELOG(
"ERROR: Mode not found\n");
220 char *xdg_config_home, *xdg_config_dirs, *config_path;
222 static const char *saved_configpath = NULL;
224 if (override_configpath != NULL) {
225 saved_configpath = override_configpath;
226 return sstrdup(saved_configpath);
229 if (saved_configpath != NULL)
230 return sstrdup(saved_configpath);
239 if ((xdg_config_home = getenv(
"XDG_CONFIG_HOME")) == NULL)
240 xdg_config_home =
"~/.config";
243 sasprintf(&config_path,
"%s/i3/config", xdg_config_home);
244 free(xdg_config_home);
251 config_path = SYSCONFDIR
"/i3/config";
256 if ((xdg_config_dirs = getenv(
"XDG_CONFIG_DIRS")) == NULL)
257 xdg_config_dirs =
"/etc/xdg";
259 char *buf =
sstrdup(xdg_config_dirs);
260 char *tok = strtok(buf,
":");
261 while (tok != NULL) {
263 sasprintf(&config_path,
"%s/i3/config", tok);
270 tok = strtok(NULL,
":");
274 die(
"Unable to find the configuration file (looked at "
275 "~/.i3/config, $XDG_CONFIG_HOME/i3/config, "
276 SYSCONFDIR
"/i3/config and $XDG_CONFIG_DIRS/i3/config)");
287 LOG(
"Parsing configfile %s\n", path);
370 workspace_set_name(ws, NULL);
392 #define REQUIRED_OPTION(name) \
393 if (config.name == NULL) \
394 die("You did not specify required configuration option " #name "\n");
397 memset(&config, 0,
sizeof(config));
400 #define INIT_COLOR(x, cborder, cbackground, ctext, cindicator) \
402 x.border = get_colorpixel(cborder); \
403 x.background = get_colorpixel(cbackground); \
404 x.text = get_colorpixel(ctext); \
405 x.indicator = get_colorpixel(cindicator); \
436 if (config.
font.
type == FONT_TYPE_NONE) {
437 ELOG(
"You did not specify required configuration option \"font\"\n");
453 if (ws->name != NULL) {
456 if (ws->text_width == 0)
458 config.
font, ws->name, ws->name_len);
462 workspace_set_name(ws, NULL);