2 #define I3__FILE__ "config_directives.c"
31 DLOG(
"Initializing criteria, current_match = %p, state = %d\n",
current_match, _state);
44 CFGFUN(criteria_add,
const char *ctype,
const char *cvalue) {
45 DLOG(
"ctype=*%s*, cvalue=*%s*\n", ctype, cvalue);
47 if (strcmp(ctype,
"class") == 0) {
52 if (strcmp(ctype,
"instance") == 0) {
57 if (strcmp(ctype,
"window_role") == 0) {
62 if (strcmp(ctype,
"con_id") == 0) {
64 long parsed = strtol(cvalue, &end, 10);
65 if (parsed == LONG_MIN ||
68 (end && *end !=
'\0')) {
69 ELOG(
"Could not parse con id \"%s\"\n", cvalue);
77 if (strcmp(ctype,
"id") == 0) {
79 long parsed = strtol(cvalue, &end, 10);
80 if (parsed == LONG_MIN ||
83 (end && *end !=
'\0')) {
84 ELOG(
"Could not parse window id \"%s\"\n", cvalue);
92 if (strcmp(ctype,
"con_mark") == 0) {
97 if (strcmp(ctype,
"title") == 0) {
102 if (strcmp(ctype,
"urgent") == 0) {
103 if (strcasecmp(cvalue,
"latest") == 0 ||
104 strcasecmp(cvalue,
"newest") == 0 ||
105 strcasecmp(cvalue,
"recent") == 0 ||
106 strcasecmp(cvalue,
"last") == 0) {
108 }
else if (strcasecmp(cvalue,
"oldest") == 0 ||
109 strcasecmp(cvalue,
"first") == 0) {
115 ELOG(
"Unknown criterion: %s\n", ctype);
125 return (strcasecmp(str,
"1") == 0 ||
126 strcasecmp(str,
"yes") == 0 ||
127 strcasecmp(str,
"true") == 0 ||
128 strcasecmp(str,
"on") == 0 ||
129 strcasecmp(str,
"enable") == 0 ||
130 strcasecmp(str,
"active") == 0);
143 if (strstr(str,
"Mod1") != NULL)
145 if (strstr(str,
"Mod2") != NULL)
147 if (strstr(str,
"Mod3") != NULL)
149 if (strstr(str,
"Mod4") != NULL)
151 if (strstr(str,
"Mod5") != NULL)
153 if (strstr(str,
"Control") != NULL ||
154 strstr(str,
"Ctrl") != NULL)
156 if (strstr(str,
"Shift") != NULL)
158 if (strstr(str,
"Mode_switch") != NULL)
174 CFGFUN(binding,
const char *bindtype,
const char *modifiers,
const char *key,
const char *release,
const char *command) {
184 CFGFUN(mode_binding,
const char *bindtype,
const char *modifiers,
const char *key,
const char *release,
const char *command) {
188 CFGFUN(enter_mode,
const char *modename) {
193 DLOG(
"\t now in mode %s\n", modename);
198 CFGFUN(exec,
const char *exectype,
const char *no_startup_id,
const char *command) {
200 new->command =
sstrdup(command);
201 new->no_startup_id = (no_startup_id != NULL);
202 if (strcmp(exectype,
"exec") == 0) {
211 ELOG(
"Match is empty, ignoring this for_window statement\n");
214 DLOG(
"\t should execute command %s for the criteria mentioned above\n", command);
216 assignment->
type = A_COMMAND;
232 CFGFUN(floating_modifier,
const char *modifiers) {
236 CFGFUN(default_orientation,
const char *orientation) {
237 if (strcmp(orientation,
"horizontal") == 0)
239 else if (strcmp(orientation,
"vertical") == 0)
245 CFGFUN(workspace_layout,
const char *layout) {
246 if (strcmp(layout,
"default") == 0)
248 else if (strcmp(layout,
"stacking") == 0 ||
249 strcmp(layout,
"stacked") == 0)
255 CFGFUN(new_window,
const char *windowtype,
const char *border,
const long width) {
259 if (strcmp(border,
"1pixel") == 0) {
262 }
else if (strcmp(border,
"none") == 0) {
265 }
else if (strcmp(border,
"pixel") == 0) {
267 border_width =
width;
270 border_width =
width;
273 if (strcmp(windowtype,
"new_window") == 0) {
274 DLOG(
"default tiled border style = %d and border width = %d\n", border_style, border_width);
278 DLOG(
"default floating border style = %d and border width = %d\n", border_style, border_width);
284 CFGFUN(hide_edge_borders,
const char *borders) {
285 if (strcmp(borders,
"vertical") == 0)
287 else if (strcmp(borders,
"horizontal") == 0)
289 else if (strcmp(borders,
"both") == 0)
291 else if (strcmp(borders,
"none") == 0)
299 CFGFUN(focus_follows_mouse,
const char *value) {
303 CFGFUN(mouse_warping,
const char *value) {
304 if (strcmp(value,
"none") == 0)
306 else if (strcmp(value,
"output") == 0)
310 CFGFUN(force_xinerama,
const char *value) {
314 CFGFUN(force_focus_wrapping,
const char *value) {
326 CFGFUN(force_display_urgency_hint,
const long duration_ms) {
330 CFGFUN(workspace,
const char *workspace,
const char *output) {
331 DLOG(
"Assigning workspace \"%s\" to output \"%s\"\n", workspace, output);
336 bool duplicate =
false;
338 if (strcasecmp(assignment->
name, workspace) == 0) {
339 ELOG(
"You have a duplicate workspace assignment for workspace \"%s\"\n",
357 CFGFUN(restart_state,
const char *path) {
361 CFGFUN(popup_during_fullscreen,
const char *value) {
362 if (strcmp(value,
"ignore") == 0) {
364 }
else if (strcmp(value,
"leave_fullscreen") == 0) {
371 CFGFUN(color_single,
const char *colorclass,
const char *color) {
376 CFGFUN(color,
const char *colorclass,
const char *border,
const char *background,
const char *text,
const char *indicator) {
377 #define APPLY_COLORS(classname) \
379 if (strcmp(colorclass, "client." #classname) == 0) { \
380 config.client.classname.border = get_colorpixel(border); \
381 config.client.classname.background = get_colorpixel(background); \
382 config.client.classname.text = get_colorpixel(text); \
383 if (indicator != NULL) { \
384 config.client.classname.indicator = get_colorpixel(indicator); \
399 ELOG(
"Match is empty, ignoring this assignment\n");
402 DLOG(
"new assignment, using above criteria, to workspace %s\n", workspace);
405 assignment->
type = A_TO_WORKSPACE;
422 current_bar.
mode = (strcmp(mode,
"dock") == 0 ? M_DOCK : (strcmp(mode,
"hide") == 0 ? M_HIDE : M_INVISIBLE));
425 CFGFUN(bar_hidden_state,
const char *hidden_state) {
426 current_bar.
hidden_state = (strcmp(hidden_state,
"hide") == 0 ? S_HIDE : S_SHOW);
444 CFGFUN(bar_modifier,
const char *modifier) {
445 if (strcmp(modifier,
"Mod1") == 0)
447 else if (strcmp(modifier,
"Mod2") == 0)
449 else if (strcmp(modifier,
"Mod3") == 0)
451 else if (strcmp(modifier,
"Mod4") == 0)
453 else if (strcmp(modifier,
"Mod5") == 0)
455 else if (strcmp(modifier,
"Control") == 0 ||
456 strcmp(modifier,
"Ctrl") == 0)
458 else if (strcmp(modifier,
"Shift") == 0)
462 CFGFUN(bar_position,
const char *position) {
463 current_bar.
position = (strcmp(position,
"top") == 0 ? P_TOP : P_BOTTOM);
466 CFGFUN(bar_i3bar_command,
const char *i3bar_command) {
471 CFGFUN(bar_color,
const char *colorclass,
const char *border,
const char *background,
const char *text) {
472 #define APPLY_COLORS(classname) \
474 if (strcmp(colorclass, #classname) == 0) { \
475 if (text != NULL) { \
477 current_bar.colors.classname##_border = sstrdup(border); \
478 current_bar.colors.classname##_bg = sstrdup(background); \
479 current_bar.colors.classname##_text = sstrdup(text); \
482 current_bar.colors.classname##_bg = sstrdup(background); \
483 current_bar.colors.classname##_text = sstrdup(border); \
496 CFGFUN(bar_socket_path,
const char *socket_path) {
506 CFGFUN(bar_color_single,
const char *colorclass,
const char *color) {
507 if (strcmp(colorclass,
"background") == 0)
509 else if (strcmp(colorclass,
"separator") == 0)
515 CFGFUN(bar_status_command,
const char *command) {
520 CFGFUN(bar_binding_mode_indicator,
const char *value) {
524 CFGFUN(bar_workspace_buttons,
const char *value) {
528 CFGFUN(bar_strip_workspace_numbers,
const char *value) {
533 DLOG(
"\t new bar configuration finished, saving.\n");
547 memcpy(bar_config, ¤t_bar,
sizeof(
Barconfig));
550 memset(¤t_bar,
'\0',
sizeof(
Barconfig));
char * font
Font specification for all text rendered on the bar.
char * sstrdup(const char *str)
Safe-wrapper around strdup which exits if malloc returns NULL (meaning that there is no more memory a...
void set_font(i3Font *font)
Defines the font to be used for the forthcoming calls.
int default_floating_border_width
bool hide_binding_mode_indicator
Hide mode button? Configuration option is 'binding_mode_indicator no' but we invert the bool for the ...
int32_t floating_minimum_width
const char * DEFAULT_BINDING_MODE
bool disable_focus_follows_mouse
By default, focus follows mouse.
Stores which workspace (by name or number) goes to which output.
int32_t floating_maximum_height
An Assignment makes specific windows go to a specific workspace/output or run a command for that wind...
static Barconfig current_bar
enum Barconfig::@5 mode
Bar display mode (hide unless modifier is pressed or show in dock mode or always hide in invisible mo...
enum Barconfig::@8 position
Bar position (bottom by default).
char * fake_outputs
Overwrites output detection (for testing), see src/fake_outputs.c.
struct regex * window_role
int32_t floating_maximum_width
Maximum and minimum dimensions of a floating window.
struct Barconfig::bar_colors colors
bool verbose
Enable verbose mode? Useful for debugging purposes.
union Assignment::@17 dest
destination workspace/output/command, depending on the type
float workspace_urgency_timer
By default, urgency is cleared immediately when switching to another workspace leads to focusing the ...
uint32_t modifiers_from_str(const char *str)
A utility function to convert a string of modifiers to the corresponding bit mask.
struct Config::config_client client
bool workspace_auto_back_and_forth
Automatic workspace back and forth switching.
void match_copy(Match *dest, Match *src)
Copies the data of a match from src to dest.
int default_orientation
Default orientation for new containers.
static Match current_match
struct regex * regex_new(const char *pattern)
Creates a new 'regex' struct containing the given pattern and a PCRE compiled regular expression...
static int criteria_next_state
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...
char * tray_output
Output on which the tray should be shown.
uint32_t get_colorpixel(const char *hex) __attribute__((const ))
Returns the colorpixel to use for the given hex color (think of HTML).
void workspace_back_and_forth(void)
Focuses the previously focused workspace.
static char * font_pattern
struct outputs_head outputs
char * id
Automatically generated ID for this bar config.
warping_t mouse_warping
By default, when switching focus to a window on a different output (e.g.
enum Barconfig::@7 modifier
Bar modifier (to show bar when in hide mode).
struct autostarts_head autostarts
Binding * configure_binding(const char *bindtype, const char *modifiers, const char *input_code, const char *release, const char *command, const char *modename)
Adds a binding from config parameters given as strings and returns a pointer to the binding structure...
struct assignments_head assignments
adjacent_t hide_edge_borders
Remove borders if they are adjacent to the screen edge.
bool strip_workspace_numbers
Strip workspace numbers? Configuration option is 'strip_workspace_numbers yes'.
char * i3bar_command
Command that should be run to execute i3bar, give a full path if i3bar is not in your $PATH...
CFGFUN(criteria_init, int _state)
static char * current_mode
const char * restart_state_path
bool force_focus_wrapping
Think of the following layout: Horizontal workspace with a tabbed con on the left of the screen and a...
#define APPLY_COLORS(classname)
border_style_t default_border
The default border style for new windows.
A 'Con' represents everything from the X11 root window down to a single X11 window.
enum Barconfig::@6 hidden_state
void * scalloc(size_t size)
Safe-wrapper around calloc which exits if malloc returns NULL (meaning that there is no more memory a...
bool force_xinerama
By default, use the RandR API for multi-monitor setups.
border_style_t default_floating_border
The default border style for new floating windows.
static bool eval_boolstr(const char *str)
#define TAILQ_INSERT_TAIL(head, elm, field)
bool hide_workspace_buttons
Hide workspace buttons? Configuration option is 'workspace_buttons no' but we invert the bool to get ...
bool match_is_empty(Match *match)
Check if a match is empty.
char * command
Command, like in command mode.
struct barconfig_head barconfigs
char ** outputs
Outputs on which this bar should show up on.
enum Assignment::@16 type
type of this assignment:
int32_t floating_minimum_height
void * smalloc(size_t size)
Safe-wrapper around malloc which exits if malloc returns NULL (meaning that there is no more memory a...
Match match
the criteria to check if a window matches
uint32_t floating_modifier
The modifier which needs to be pressed in combination with your mouse buttons to do things with float...
#define TAILQ_FOREACH(var, head, field)
void * srealloc(void *ptr, size_t size)
Safe-wrapper around realloc which exits if realloc returns NULL (meaning that there is no more memory...
char * status_command
Command that should be run to get a statusline, for example 'i3status'.
Holds the status bar configuration (i3bar).
enum Config::@4 popup_during_fullscreen
What should happen when a new popup is opened during fullscreen mode.
char * socket_path
Path to the i3 IPC socket.
struct autostarts_always_head autostarts_always
Holds a command specified by either an:
i3Font load_font(const char *pattern, const bool fallback)
Loads a font for usage, also getting its height.
struct ws_assignments_head ws_assignments
void match_init(Match *match)
int num_outputs
Number of outputs in the outputs array.