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;
64 if (bind->
release == B_UPON_KEYRELEASE_IGNORE_MODS)
65 bind->
release = B_UPON_KEYRELEASE;
72 if (bind->
release == B_UPON_KEYRELEASE && !key_release)
73 bind->
release = B_UPON_KEYRELEASE_IGNORE_MODS;
81 if (bind->
mods != modifiers &&
82 (bind->
release != B_UPON_KEYRELEASE_IGNORE_MODS ||
87 if ((bind->
release == B_UPON_KEYPRESS && key_release) ||
88 (bind->
release >= B_UPON_KEYRELEASE && !key_release))
93 if (bind->
symbol != NULL) {
96 &keycode,
sizeof(xcb_keycode_t)) != NULL)
117 min_keycode = xcb_get_setup(
conn)->min_keycode,
118 max_keycode = xcb_get_setup(
conn)->max_keycode;
125 keysym = XStringToKeysym(bind->
symbol);
126 if (keysym == NoSymbol) {
127 ELOG(
"Could not translate string to key symbol: \"%s\"\n",
141 for (i = min_keycode; i && i <= max_keycode; i++) {
142 if ((xcb_key_symbols_get_keysym(
keysyms, i, col) != keysym) &&
143 (xcb_key_symbols_get_keysym(
keysyms, i, col+1) != keysym))
147 (
sizeof(xcb_keycode_t) *
152 DLOG(
"Translated symbol \"%s\" to %d keycode\n", bind->
symbol,
187 LOG(
"Switching to mode %s\n", new_mode);
190 if (strcasecmp(mode->
name, new_mode) != 0)
200 ELOG(
"ERROR: Mode not found\n");
212 char *xdg_config_home, *xdg_config_dirs, *config_path;
214 static const char *saved_configpath = NULL;
216 if (override_configpath != NULL) {
217 saved_configpath = override_configpath;
218 return sstrdup(saved_configpath);
221 if (saved_configpath != NULL)
222 return sstrdup(saved_configpath);
231 if ((xdg_config_home = getenv(
"XDG_CONFIG_HOME")) == NULL)
232 xdg_config_home =
"~/.config";
235 sasprintf(&config_path,
"%s/i3/config", xdg_config_home);
236 free(xdg_config_home);
243 config_path = SYSCONFDIR
"/i3/config";
248 if ((xdg_config_dirs = getenv(
"XDG_CONFIG_DIRS")) == NULL)
249 xdg_config_dirs =
"/etc/xdg";
251 char *buf =
sstrdup(xdg_config_dirs);
252 char *tok = strtok(buf,
":");
253 while (tok != NULL) {
255 sasprintf(&config_path,
"%s/i3/config", tok);
262 tok = strtok(NULL,
":");
266 die(
"Unable to find the configuration file (looked at "
267 "~/.i3/config, $XDG_CONFIG_HOME/i3/config, "
268 SYSCONFDIR
"/i3/config and $XDG_CONFIG_DIRS/i3/config)");
279 LOG(
"Parsing configfile %s\n", path);
362 workspace_set_name(ws, NULL);
384 #define REQUIRED_OPTION(name) \
385 if (config.name == NULL) \
386 die("You did not specify required configuration option " #name "\n");
389 memset(&config, 0,
sizeof(config));
392 #define INIT_COLOR(x, cborder, cbackground, ctext, cindicator) \
394 x.border = get_colorpixel(cborder); \
395 x.background = get_colorpixel(cbackground); \
396 x.text = get_colorpixel(ctext); \
397 x.indicator = get_colorpixel(cindicator); \
423 if (config.
font.
type == FONT_TYPE_NONE) {
424 ELOG(
"You did not specify required configuration option \"font\"\n");
440 if (ws->name != NULL) {
443 if (ws->text_width == 0)
445 config.
font, ws->name, ws->name_len);
449 workspace_set_name(ws, NULL);