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 with modifiers %d (with mod_mask_lock %d)\n", keycode, bind->
mods, bind->
mods | XCB_MOD_MASK_LOCK);
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;
74 if (bind->
mods != modifiers &&
75 (bind->
release != B_UPON_KEYRELEASE_IGNORE_MODS ||
81 if (bind->
symbol != NULL) {
84 &keycode,
sizeof(xcb_keycode_t)) == NULL)
97 if (bind->
release == B_UPON_KEYRELEASE && !key_release)
98 bind->
release = B_UPON_KEYRELEASE_IGNORE_MODS;
101 if ((bind->
release == B_UPON_KEYPRESS && key_release) ||
102 (bind->
release >= B_UPON_KEYRELEASE && !key_release))
120 min_keycode = xcb_get_setup(
conn)->min_keycode,
121 max_keycode = xcb_get_setup(
conn)->max_keycode;
128 keysym = XStringToKeysym(bind->
symbol);
129 if (keysym == NoSymbol) {
130 ELOG(
"Could not translate string to key symbol: \"%s\"\n",
144 for (i = min_keycode; i && i <= max_keycode; i++) {
145 if ((xcb_key_symbols_get_keysym(
keysyms, i, col) != keysym) &&
146 (xcb_key_symbols_get_keysym(
keysyms, i, col+1) != keysym))
150 (
sizeof(xcb_keycode_t) *
155 DLOG(
"Translated symbol \"%s\" to %d keycode\n", bind->
symbol,
190 LOG(
"Switching to mode %s\n", new_mode);
193 if (strcasecmp(mode->
name, new_mode) != 0)
210 ELOG(
"ERROR: Mode not found\n");
222 char *xdg_config_home, *xdg_config_dirs, *config_path;
224 static const char *saved_configpath = NULL;
226 if (override_configpath != NULL) {
227 saved_configpath = override_configpath;
228 return sstrdup(saved_configpath);
231 if (saved_configpath != NULL)
232 return sstrdup(saved_configpath);
241 if ((xdg_config_home = getenv(
"XDG_CONFIG_HOME")) == NULL)
242 xdg_config_home =
"~/.config";
245 sasprintf(&config_path,
"%s/i3/config", xdg_config_home);
246 free(xdg_config_home);
253 config_path = SYSCONFDIR
"/i3/config";
258 if ((xdg_config_dirs = getenv(
"XDG_CONFIG_DIRS")) == NULL)
259 xdg_config_dirs =
"/etc/xdg";
261 char *buf =
sstrdup(xdg_config_dirs);
262 char *tok = strtok(buf,
":");
263 while (tok != NULL) {
265 sasprintf(&config_path,
"%s/i3/config", tok);
272 tok = strtok(NULL,
":");
276 die(
"Unable to find the configuration file (looked at "
277 "~/.i3/config, $XDG_CONFIG_HOME/i3/config, "
278 SYSCONFDIR
"/i3/config and $XDG_CONFIG_DIRS/i3/config)");
289 LOG(
"Parsing configfile %s\n", path);
372 workspace_set_name(ws, NULL);
394 #define REQUIRED_OPTION(name) \
395 if (config.name == NULL) \
396 die("You did not specify required configuration option " #name "\n");
399 memset(&config, 0,
sizeof(config));
402 #define INIT_COLOR(x, cborder, cbackground, ctext, cindicator) \
404 x.border = get_colorpixel(cborder); \
405 x.background = get_colorpixel(cbackground); \
406 x.text = get_colorpixel(ctext); \
407 x.indicator = get_colorpixel(cindicator); \
438 if (config.
font.
type == FONT_TYPE_NONE) {
439 ELOG(
"You did not specify required configuration option \"font\"\n");
455 if (ws->name != NULL) {
458 if (ws->text_width == 0)
460 config.
font, ws->name, ws->name_len);
464 workspace_set_name(ws, NULL);