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);
The configuration file can contain multiple sets of bindings.
char * font
Font specification for all text rendered on the bar.
border_style_t default_border
The default border style for new windows.
void load_configuration(xcb_connection_t *conn, const char *override_configpath, bool reload)
Reads the configuration from ~/.i3/config or /etc/i3/config if not found.
A 'Con' represents everything from the X11 root window down to a single X11 window.
char * symbol
Symbol the user specified in configfile, if any.
struct all_cons_head all_cons
struct Colortriple unfocused
struct barconfig_head barconfigs
char * inactive_workspace_bg
An Assignment makes specific windows go to a specific workspace/output or run a command for that wind...
enum Barconfig::@5 mode
Bar display mode (hide unless modifier is pressed or show in dock mode or always hide in invisible mo...
struct Colortriple urgent
#define TAILQ_EMPTY(head)
char * focused_workspace_bg
static char * get_config_path(const char *override_configpath)
char * sstrdup(const char *str)
Safe-wrapper around strdup which exits if malloc returns NULL (meaning that there is no more memory a...
char * urgent_workspace_border
struct Barconfig::bar_colors colors
char * urgent_workspace_text
union Assignment::@17 dest
destination workspace/output/command, depending on the type
char * urgent_workspace_bg
void * scalloc(size_t size)
Safe-wrapper around calloc which exits if malloc returns NULL (meaning that there is no more memory a...
struct Config::config_client client
Binding * get_binding(uint16_t modifiers, bool key_release, xcb_keycode_t keycode)
Returns a pointer to the Binding with the specified modifiers and keycode or NULL if no such binding ...
char * resolve_tilde(const char *path)
This function resolves ~ in pathnames.
float workspace_urgency_timer
By default, urgency is cleared immediately when switching to another workspace leads to focusing the ...
#define TAILQ_REMOVE(head, elm, field)
static void parse_configuration(const char *override_configpath)
Holds a keybinding, consisting of a keycode combined with modifiers and the command which is executed...
#define GRAB_KEY(modifier)
uint32_t get_colorpixel(const char *hex) __attribute__((const ))
Returns the colorpixel to use for the given hex color (think of HTML).
char * active_workspace_border
void parse_file(const char *f)
Parses the given file by first replacing the variables, then calling parse_config and possibly launch...
void match_free(Match *match)
Frees the given match.
int default_orientation
Default orientation for new containers.
char * command
Command, like in command mode.
void update_barconfig()
Sends the current bar configuration as an event to all barconfig_update listeners.
char * tray_output
Output on which the tray should be shown.
Holds part of the configuration (the part which is not already in dedicated structures in include/dat...
enum Binding::@10 release
If true, the binding should be executed upon a KeyRelease event, not a KeyPress (the default)...
#define TAILQ_HEAD_INITIALIZER(head)
void ipc_send_event(const char *event, uint32_t message_type, const char *payload)
Sends the specified event to all IPC clients which are currently connected and subscribed to this kin...
char * id
Automatically generated ID for this bar config.
int sasprintf(char **strp, const char *fmt,...)
Safe-wrapper around asprintf which exits if it returns -1 (meaning that there is no more memory avail...
border_style_t default_floating_border
The default border style for new floating windows.
struct Colortriple urgent
#define INIT_COLOR(x, cborder, cbackground, ctext, cindicator)
enum Font::@22 type
The type of font.
char * focused_workspace_text
struct Config::config_bar bar
i3Font load_font(const char *pattern, const bool fallback)
Loads a font for usage, also getting its height.
void x_deco_recurse(Con *con)
Recursively calls x_draw_decoration.
char * focused_workspace_border
char * active_workspace_text
char * i3bar_command
Command that should be run to execute i3bar, give a full path if i3bar is not in your $PATH...
void switch_mode(const char *new_mode)
Switches the key bindings to the given mode, if the mode exists.
struct Colortriple focused
#define TAILQ_FIRST(head)
void free_font(void)
Frees the resources taken by the current font.
char * current_configpath
struct Colortriple focused
struct Colortriple focused_inactive
enum Barconfig::@6 hidden_state
void * srealloc(void *ptr, size_t size)
Safe-wrapper around realloc which exits if realloc returns NULL (meaning that there is no more memory...
#define SLIST_FOREACH(var, head, field)
uint32_t keycode
Keycode to bind.
struct deco_render_params * deco_render_params
Cache for the decoration rendering.
#define TAILQ_FOREACH(var, head, field)
void translate_keysyms(void)
Translates keysymbols to keycodes for all bindings which use keysyms.
uint32_t mods
Bitmask consisting of BIND_MOD_1, BIND_MODE_SWITCH, …
#define SLIST_INSERT_HEAD(head, elm, field)
char ** outputs
Outputs on which this bar should show up on.
#define SLIST_FIRST(head)
struct bindings_head * bindings
enum Assignment::@16 type
type of this assignment:
static void grab_keycode_for_binding(xcb_connection_t *conn, Binding *bind, uint32_t keycode)
struct Colortriple unfocused
struct bindings_head * bindings
Match match
the criteria to check if a window matches
xcb_keycode_t * translated_to
Only in use if symbol != NULL.
char * active_workspace_bg
char * inactive_workspace_text
void set_font(i3Font *font)
Defines the font to be used for the forthcoming calls.
#define SLIST_REMOVE(head, elm, type, field)
void ungrab_all_keys(xcb_connection_t *conn)
Ungrabs all keys, to be called before re-grabbing the keys because of a mapping_notify event or a con...
#define SLIST_EMPTY(head)
bool path_exists(const char *path)
Checks if the given path exists by calling stat().
char * status_command
Command that should be run to get a statusline, for example 'i3status'.
Holds the status bar configuration (i3bar).
char * socket_path
Path to the i3 IPC socket.
xcb_key_symbols_t * keysyms
void grab_all_keys(xcb_connection_t *conn, bool bind_mode_switch)
Grab the bound keys (tell X to send us keypress events for those keycodes)
char * inactive_workspace_border
struct assignments_head assignments
unsigned int xcb_numlock_mask
int predict_text_width(i3String *text)
Predict the text width in pixels for the given text.
int num_outputs
Number of outputs in the outputs array.