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);
139 if (strstr(str,
"Mod1") != NULL)
141 if (strstr(str,
"Mod2") != NULL)
143 if (strstr(str,
"Mod3") != NULL)
145 if (strstr(str,
"Mod4") != NULL)
147 if (strstr(str,
"Mod5") != NULL)
149 if (strstr(str,
"Control") != NULL ||
150 strstr(str,
"Ctrl") != NULL)
152 if (strstr(str,
"Shift") != NULL)
154 if (strstr(str,
"Mode_switch") != NULL)
171 CFGFUN(binding,
const char *bindtype,
const char *modifiers,
const char *key,
const char *release,
const char *command) {
173 DLOG(
"bindtype %s, modifiers %s, key %s, release %s\n", bindtype, modifiers, key, release);
174 new_binding->
release = (release != NULL ? B_UPON_KEYRELEASE : B_UPON_KEYPRESS);
175 if (strcmp(bindtype,
"bindsym") == 0) {
179 new_binding->
keycode = atoi(key);
180 if (new_binding->
keycode == 0) {
181 ELOG(
"Could not parse \"%s\" as a keycode, ignoring this binding.\n", key);
197 CFGFUN(mode_binding,
const char *bindtype,
const char *modifiers,
const char *key,
const char *release,
const char *command) {
199 DLOG(
"bindtype %s, modifiers %s, key %s, release %s\n", bindtype, modifiers, key, release);
200 new_binding->
release = (release != NULL ? B_UPON_KEYRELEASE : B_UPON_KEYPRESS);
201 if (strcmp(bindtype,
"bindsym") == 0) {
205 new_binding->
keycode = atoi(key);
206 if (new_binding->
keycode == 0) {
207 ELOG(
"Could not parse \"%s\" as a keycode, ignoring this binding.\n", key);
216 CFGFUN(enter_mode,
const char *modename) {
217 if (strcasecmp(modename,
"default") == 0) {
218 ELOG(
"You cannot use the name \"default\" for your mode\n");
221 DLOG(
"\t now in mode %s\n", modename);
230 CFGFUN(exec,
const char *exectype,
const char *no_startup_id,
const char *command) {
232 new->command =
sstrdup(command);
233 new->no_startup_id = (no_startup_id != NULL);
234 if (strcmp(exectype,
"exec") == 0) {
243 ELOG(
"Match is empty, ignoring this for_window statement\n");
246 DLOG(
"\t should execute command %s for the criteria mentioned above\n", command);
248 assignment->
type = A_COMMAND;
264 CFGFUN(floating_modifier,
const char *modifiers) {
268 CFGFUN(default_orientation,
const char *orientation) {
269 if (strcmp(orientation,
"horizontal") == 0)
271 else if (strcmp(orientation,
"vertical") == 0)
276 CFGFUN(workspace_layout,
const char *layout) {
277 if (strcmp(layout,
"default") == 0)
279 else if (strcmp(layout,
"stacking") == 0 ||
280 strcmp(layout,
"stacked") == 0)
285 CFGFUN(new_window,
const char *windowtype,
const char *border,
const long width) {
292 if (strcmp(border,
"1pixel") == 0) {
295 }
else if (strcmp(border,
"none") == 0) {
298 }
else if (strcmp(border,
"pixel") == 0) {
300 border_width =
width;
303 border_width =
width;
306 if (strcmp(windowtype,
"new_window") == 0) {
315 CFGFUN(hide_edge_borders,
const char *borders) {
316 if (strcmp(borders,
"vertical") == 0)
318 else if (strcmp(borders,
"horizontal") == 0)
320 else if (strcmp(borders,
"both") == 0)
322 else if (strcmp(borders,
"none") == 0)
329 CFGFUN(focus_follows_mouse,
const char *value) {
333 CFGFUN(force_xinerama,
const char *value) {
337 CFGFUN(force_focus_wrapping,
const char *value) {
349 CFGFUN(force_display_urgency_hint,
const long duration_ms) {
353 CFGFUN(workspace,
const char *workspace,
const char *output) {
354 DLOG(
"Assigning workspace \"%s\" to output \"%s\"\n", workspace, output);
359 bool duplicate =
false;
361 if (strcasecmp(assignment->
name, workspace) == 0) {
362 ELOG(
"You have a duplicate workspace assignment for workspace \"%s\"\n",
380 CFGFUN(restart_state,
const char *path) {
384 CFGFUN(popup_during_fullscreen,
const char *value) {
385 if (strcmp(value,
"ignore") == 0) {
387 }
else if (strcmp(value,
"leave_fullscreen") == 0) {
394 CFGFUN(color_single,
const char *colorclass,
const char *color) {
399 CFGFUN(color,
const char *colorclass,
const char *border,
const char *background,
const char *text,
const char *indicator) {
400 #define APPLY_COLORS(classname) \
402 if (strcmp(colorclass, "client." #classname) == 0) { \
403 config.client.classname.border = get_colorpixel(border); \
404 config.client.classname.background = get_colorpixel(background); \
405 config.client.classname.text = get_colorpixel(text); \
406 if (indicator != NULL) { \
407 config.client. classname .indicator = get_colorpixel(indicator); \
422 ELOG(
"Match is empty, ignoring this assignment\n");
425 DLOG(
"new assignment, using above criteria, to workspace %s\n", workspace);
428 assignment->
type = A_TO_WORKSPACE;
445 current_bar.
mode = (strcmp(mode,
"dock") == 0 ? M_DOCK : (strcmp(mode,
"hide") == 0 ? M_HIDE : M_INVISIBLE));
448 CFGFUN(bar_hidden_state,
const char *hidden_state) {
449 current_bar.
hidden_state = (strcmp(hidden_state,
"hide") == 0 ? S_HIDE : S_SHOW);
467 CFGFUN(bar_modifier,
const char *modifier) {
468 if (strcmp(modifier,
"Mod1") == 0)
470 else if (strcmp(modifier,
"Mod2") == 0)
472 else if (strcmp(modifier,
"Mod3") == 0)
474 else if (strcmp(modifier,
"Mod4") == 0)
476 else if (strcmp(modifier,
"Mod5") == 0)
478 else if (strcmp(modifier,
"Control") == 0 ||
479 strcmp(modifier,
"Ctrl") == 0)
481 else if (strcmp(modifier,
"Shift") == 0)
485 CFGFUN(bar_position,
const char *position) {
486 current_bar.
position = (strcmp(position,
"top") == 0 ? P_TOP : P_BOTTOM);
489 CFGFUN(bar_i3bar_command,
const char *i3bar_command) {
494 CFGFUN(bar_color,
const char *colorclass,
const char *border,
const char *background,
const char *text) {
495 #define APPLY_COLORS(classname) \
497 if (strcmp(colorclass, #classname) == 0) { \
498 if (text != NULL) { \
500 current_bar.colors. classname ## _border = sstrdup(border); \
501 current_bar.colors. classname ## _bg = sstrdup(background); \
502 current_bar.colors. classname ## _text = sstrdup(text); \
505 current_bar.colors. classname ## _bg = sstrdup(background); \
506 current_bar.colors. classname ## _text = sstrdup(border); \
519 CFGFUN(bar_socket_path,
const char *socket_path) {
529 CFGFUN(bar_color_single,
const char *colorclass,
const char *color) {
530 if (strcmp(colorclass,
"background") == 0)
532 else if (strcmp(colorclass,
"separator") == 0)
538 CFGFUN(bar_status_command,
const char *command) {
543 CFGFUN(bar_binding_mode_indicator,
const char *value) {
547 CFGFUN(bar_workspace_buttons,
const char *value) {
552 DLOG(
"\t new bar configuration finished, saving.\n");
566 memcpy(bar_config, ¤t_bar,
sizeof(
Barconfig));
569 memset(¤t_bar,
'\0',
sizeof(
Barconfig));