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");
225 hidden_state =
"show";
229 hidden_state =
"hide";
234 switch (current->
mode) {
249 sasprintf(&event_msg,
"{ \"id\":\"%s\", \"hidden_state\":\"%s\", \"mode\":\"%s\" }", current->
id, hidden_state, mode);
251 ipc_send_event(
"barconfig_update", I3_IPC_EVENT_BARCONFIG_UPDATE, event_msg);
265 char *xdg_config_home, *xdg_config_dirs, *config_path;
267 static const char *saved_configpath = NULL;
269 if (override_configpath != NULL) {
270 saved_configpath = override_configpath;
271 return sstrdup(saved_configpath);
274 if (saved_configpath != NULL)
275 return sstrdup(saved_configpath);
284 if ((xdg_config_home = getenv(
"XDG_CONFIG_HOME")) == NULL)
285 xdg_config_home =
"~/.config";
288 sasprintf(&config_path,
"%s/i3/config", xdg_config_home);
289 free(xdg_config_home);
296 config_path = SYSCONFDIR
"/i3/config";
301 if ((xdg_config_dirs = getenv(
"XDG_CONFIG_DIRS")) == NULL)
302 xdg_config_dirs =
"/etc/xdg";
304 char *buf =
sstrdup(xdg_config_dirs);
305 char *tok = strtok(buf,
":");
306 while (tok != NULL) {
308 sasprintf(&config_path,
"%s/i3/config", tok);
315 tok = strtok(NULL,
":");
319 die(
"Unable to find the configuration file (looked at "
320 "~/.i3/config, $XDG_CONFIG_HOME/i3/config, "
321 SYSCONFDIR
"/i3/config and $XDG_CONFIG_DIRS/i3/config)");
332 LOG(
"Parsing configfile %s\n", path);
415 workspace_set_name(ws, NULL);
437 #define REQUIRED_OPTION(name) \
438 if (config.name == NULL) \
439 die("You did not specify required configuration option " #name "\n");
442 memset(&config, 0,
sizeof(config));
445 #define INIT_COLOR(x, cborder, cbackground, ctext, cindicator) \
447 x.border = get_colorpixel(cborder); \
448 x.background = get_colorpixel(cbackground); \
449 x.text = get_colorpixel(ctext); \
450 x.indicator = get_colorpixel(cindicator); \
481 if (config.
font.
type == FONT_TYPE_NONE) {
482 ELOG(
"You did not specify required configuration option \"font\"\n");
498 if (ws->name != NULL) {
501 if (ws->text_width == 0)
503 config.
font, ws->name, ws->name_len);
507 workspace_set_name(ws, NULL);