]> git.sur5r.net Git - i3/i3/blob - src/config_directives.c
0e477b703928ba11d44631141406c1b718c4ba8e
[i3/i3] / src / config_directives.c
1 #undef I3__FILE__
2 #define I3__FILE__ "config_directives.c"
3 /*
4  * vim:ts=4:sw=4:expandtab
5  *
6  * i3 - an improved dynamic tiling window manager
7  * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
8  *
9  * config_directives.c: all config storing functions (see config_parser.c)
10  *
11  */
12 #include <float.h>
13 #include <stdarg.h>
14
15 #include "all.h"
16
17 /*******************************************************************************
18  * Criteria functions.
19  ******************************************************************************/
20
21 static int criteria_next_state;
22
23 /*
24  * Initializes the specified 'Match' data structure and the initial state of
25  * commands.c for matching target windows of a command.
26  *
27  */
28 CFGFUN(criteria_init, int _state) {
29     criteria_next_state = _state;
30
31     DLOG("Initializing criteria, current_match = %p, state = %d\n", current_match, _state);
32     match_init(current_match);
33 }
34
35 CFGFUN(criteria_pop_state) {
36     result->next_state = criteria_next_state;
37 }
38
39 /*
40  * Interprets a ctype=cvalue pair and adds it to the current match
41  * specification.
42  *
43  */
44 CFGFUN(criteria_add, const char *ctype, const char *cvalue) {
45     DLOG("ctype=*%s*, cvalue=*%s*\n", ctype, cvalue);
46
47     if (strcmp(ctype, "class") == 0) {
48         current_match->class = regex_new(cvalue);
49         return;
50     }
51
52     if (strcmp(ctype, "instance") == 0) {
53         current_match->instance = regex_new(cvalue);
54         return;
55     }
56
57     if (strcmp(ctype, "window_role") == 0) {
58         current_match->window_role = regex_new(cvalue);
59         return;
60     }
61
62     if (strcmp(ctype, "con_id") == 0) {
63         char *end;
64         long parsed = strtol(cvalue, &end, 10);
65         if (parsed == LONG_MIN ||
66             parsed == LONG_MAX ||
67             parsed < 0 ||
68             (end && *end != '\0')) {
69             ELOG("Could not parse con id \"%s\"\n", cvalue);
70         } else {
71             current_match->con_id = (Con *)parsed;
72             DLOG("id as int = %p\n", current_match->con_id);
73         }
74         return;
75     }
76
77     if (strcmp(ctype, "id") == 0) {
78         char *end;
79         long parsed = strtol(cvalue, &end, 10);
80         if (parsed == LONG_MIN ||
81             parsed == LONG_MAX ||
82             parsed < 0 ||
83             (end && *end != '\0')) {
84             ELOG("Could not parse window id \"%s\"\n", cvalue);
85         } else {
86             current_match->id = parsed;
87             DLOG("window id as int = %d\n", current_match->id);
88         }
89         return;
90     }
91
92     if (strcmp(ctype, "window_type") == 0) {
93         if (strcasecmp(cvalue, "normal") == 0)
94             current_match->window_type = A__NET_WM_WINDOW_TYPE_NORMAL;
95         else if (strcasecmp(cvalue, "dialog") == 0)
96             current_match->window_type = A__NET_WM_WINDOW_TYPE_DIALOG;
97         else if (strcasecmp(cvalue, "utility") == 0)
98             current_match->window_type = A__NET_WM_WINDOW_TYPE_UTILITY;
99         else if (strcasecmp(cvalue, "toolbar") == 0)
100             current_match->window_type = A__NET_WM_WINDOW_TYPE_TOOLBAR;
101         else if (strcasecmp(cvalue, "splash") == 0)
102             current_match->window_type = A__NET_WM_WINDOW_TYPE_SPLASH;
103         else if (strcasecmp(cvalue, "menu") == 0)
104             current_match->window_type = A__NET_WM_WINDOW_TYPE_MENU;
105         else if (strcasecmp(cvalue, "dropdown_menu") == 0)
106             current_match->window_type = A__NET_WM_WINDOW_TYPE_DROPDOWN_MENU;
107         else if (strcasecmp(cvalue, "popup_menu") == 0)
108             current_match->window_type = A__NET_WM_WINDOW_TYPE_POPUP_MENU;
109         else if (strcasecmp(cvalue, "tooltip") == 0)
110             current_match->window_type = A__NET_WM_WINDOW_TYPE_TOOLTIP;
111         else
112             ELOG("unknown window_type value \"%s\"\n", cvalue);
113
114         return;
115     }
116
117     if (strcmp(ctype, "con_mark") == 0) {
118         current_match->mark = regex_new(cvalue);
119         return;
120     }
121
122     if (strcmp(ctype, "title") == 0) {
123         current_match->title = regex_new(cvalue);
124         return;
125     }
126
127     if (strcmp(ctype, "urgent") == 0) {
128         if (strcasecmp(cvalue, "latest") == 0 ||
129             strcasecmp(cvalue, "newest") == 0 ||
130             strcasecmp(cvalue, "recent") == 0 ||
131             strcasecmp(cvalue, "last") == 0) {
132             current_match->urgent = U_LATEST;
133         } else if (strcasecmp(cvalue, "oldest") == 0 ||
134                    strcasecmp(cvalue, "first") == 0) {
135             current_match->urgent = U_OLDEST;
136         }
137         return;
138     }
139
140     ELOG("Unknown criterion: %s\n", ctype);
141 }
142
143 /* TODO: refactor the above criteria code into a single file (with src/commands.c). */
144
145 /*******************************************************************************
146  * Utility functions
147  ******************************************************************************/
148
149 static bool eval_boolstr(const char *str) {
150     return (strcasecmp(str, "1") == 0 ||
151             strcasecmp(str, "yes") == 0 ||
152             strcasecmp(str, "true") == 0 ||
153             strcasecmp(str, "on") == 0 ||
154             strcasecmp(str, "enable") == 0 ||
155             strcasecmp(str, "active") == 0);
156 }
157
158 /*
159  * A utility function to convert a string of modifiers to the corresponding bit
160  * mask.
161  */
162 uint32_t modifiers_from_str(const char *str) {
163     /* It might be better to use strtok() here, but the simpler strstr() should
164      * do for now. */
165     uint32_t result = 0;
166     if (str == NULL)
167         return result;
168     if (strstr(str, "Mod1") != NULL)
169         result |= BIND_MOD1;
170     if (strstr(str, "Mod2") != NULL)
171         result |= BIND_MOD2;
172     if (strstr(str, "Mod3") != NULL)
173         result |= BIND_MOD3;
174     if (strstr(str, "Mod4") != NULL)
175         result |= BIND_MOD4;
176     if (strstr(str, "Mod5") != NULL)
177         result |= BIND_MOD5;
178     if (strstr(str, "Control") != NULL ||
179         strstr(str, "Ctrl") != NULL)
180         result |= BIND_CONTROL;
181     if (strstr(str, "Shift") != NULL)
182         result |= BIND_SHIFT;
183     if (strstr(str, "Mode_switch") != NULL)
184         result |= BIND_MODE_SWITCH;
185     return result;
186 }
187
188 static char *font_pattern;
189
190 CFGFUN(font, const char *font) {
191     config.font = load_font(font, true);
192     set_font(&config.font);
193
194     /* Save the font pattern for using it as bar font later on */
195     FREE(font_pattern);
196     font_pattern = sstrdup(font);
197 }
198
199 CFGFUN(binding, const char *bindtype, const char *modifiers, const char *key, const char *release, const char *border, const char *whole_window, const char *command) {
200     configure_binding(bindtype, modifiers, key, release, border, whole_window, command, DEFAULT_BINDING_MODE);
201 }
202
203 /*******************************************************************************
204  * Mode handling
205  ******************************************************************************/
206
207 static char *current_mode;
208
209 CFGFUN(mode_binding, const char *bindtype, const char *modifiers, const char *key, const char *release, const char *border, const char *whole_window, const char *command) {
210     configure_binding(bindtype, modifiers, key, release, border, whole_window, command, current_mode);
211 }
212
213 CFGFUN(enter_mode, const char *modename) {
214     if (strcasecmp(modename, DEFAULT_BINDING_MODE) == 0) {
215         ELOG("You cannot use the name %s for your mode\n", DEFAULT_BINDING_MODE);
216         exit(1);
217     }
218     DLOG("\t now in mode %s\n", modename);
219     FREE(current_mode);
220     current_mode = sstrdup(modename);
221 }
222
223 CFGFUN(exec, const char *exectype, const char *no_startup_id, const char *command) {
224     struct Autostart *new = smalloc(sizeof(struct Autostart));
225     new->command = sstrdup(command);
226     new->no_startup_id = (no_startup_id != NULL);
227     if (strcmp(exectype, "exec") == 0) {
228         TAILQ_INSERT_TAIL(&autostarts, new, autostarts);
229     } else {
230         TAILQ_INSERT_TAIL(&autostarts_always, new, autostarts_always);
231     }
232 }
233
234 CFGFUN(for_window, const char *command) {
235     if (match_is_empty(current_match)) {
236         ELOG("Match is empty, ignoring this for_window statement\n");
237         return;
238     }
239     DLOG("\t should execute command %s for the criteria mentioned above\n", command);
240     Assignment *assignment = scalloc(sizeof(Assignment));
241     assignment->type = A_COMMAND;
242     match_copy(&(assignment->match), current_match);
243     assignment->dest.command = sstrdup(command);
244     TAILQ_INSERT_TAIL(&assignments, assignment, assignments);
245 }
246
247 CFGFUN(floating_minimum_size, const long width, const long height) {
248     config.floating_minimum_width = width;
249     config.floating_minimum_height = height;
250 }
251
252 CFGFUN(floating_maximum_size, const long width, const long height) {
253     config.floating_maximum_width = width;
254     config.floating_maximum_height = height;
255 }
256
257 CFGFUN(floating_modifier, const char *modifiers) {
258     config.floating_modifier = modifiers_from_str(modifiers);
259 }
260
261 CFGFUN(default_orientation, const char *orientation) {
262     if (strcmp(orientation, "horizontal") == 0)
263         config.default_orientation = HORIZ;
264     else if (strcmp(orientation, "vertical") == 0)
265         config.default_orientation = VERT;
266     else
267         config.default_orientation = NO_ORIENTATION;
268 }
269
270 CFGFUN(workspace_layout, const char *layout) {
271     if (strcmp(layout, "default") == 0)
272         config.default_layout = L_DEFAULT;
273     else if (strcmp(layout, "stacking") == 0 ||
274              strcmp(layout, "stacked") == 0)
275         config.default_layout = L_STACKED;
276     else
277         config.default_layout = L_TABBED;
278 }
279
280 CFGFUN(new_window, const char *windowtype, const char *border, const long width) {
281     int border_style;
282     int border_width;
283
284     if (strcmp(border, "1pixel") == 0) {
285         border_style = BS_PIXEL;
286         border_width = 1;
287     } else if (strcmp(border, "none") == 0) {
288         border_style = BS_NONE;
289         border_width = 0;
290     } else if (strcmp(border, "pixel") == 0) {
291         border_style = BS_PIXEL;
292         border_width = width;
293     } else {
294         border_style = BS_NORMAL;
295         border_width = width;
296     }
297
298     if (strcmp(windowtype, "new_window") == 0) {
299         DLOG("default tiled border style = %d and border width = %d (%d physical px)\n",
300              border_style, border_width, logical_px(border_width));
301         config.default_border = border_style;
302         config.default_border_width = logical_px(border_width);
303     } else {
304         DLOG("default floating border style = %d and border width = %d (%d physical px)\n",
305              border_style, border_width, logical_px(border_width));
306         config.default_floating_border = border_style;
307         config.default_floating_border_width = logical_px(border_width);
308     }
309 }
310
311 CFGFUN(hide_edge_borders, const char *borders) {
312     if (strcmp(borders, "vertical") == 0)
313         config.hide_edge_borders = ADJ_LEFT_SCREEN_EDGE | ADJ_RIGHT_SCREEN_EDGE;
314     else if (strcmp(borders, "horizontal") == 0)
315         config.hide_edge_borders = ADJ_UPPER_SCREEN_EDGE | ADJ_LOWER_SCREEN_EDGE;
316     else if (strcmp(borders, "both") == 0)
317         config.hide_edge_borders = ADJ_LEFT_SCREEN_EDGE | ADJ_RIGHT_SCREEN_EDGE | ADJ_UPPER_SCREEN_EDGE | ADJ_LOWER_SCREEN_EDGE;
318     else if (strcmp(borders, "none") == 0)
319         config.hide_edge_borders = ADJ_NONE;
320     else if (eval_boolstr(borders))
321         config.hide_edge_borders = ADJ_LEFT_SCREEN_EDGE | ADJ_RIGHT_SCREEN_EDGE;
322     else
323         config.hide_edge_borders = ADJ_NONE;
324 }
325
326 CFGFUN(focus_follows_mouse, const char *value) {
327     config.disable_focus_follows_mouse = !eval_boolstr(value);
328 }
329
330 CFGFUN(mouse_warping, const char *value) {
331     if (strcmp(value, "none") == 0)
332         config.mouse_warping = POINTER_WARPING_NONE;
333     else if (strcmp(value, "output") == 0)
334         config.mouse_warping = POINTER_WARPING_OUTPUT;
335 }
336
337 CFGFUN(force_xinerama, const char *value) {
338     config.force_xinerama = eval_boolstr(value);
339 }
340
341 CFGFUN(force_focus_wrapping, const char *value) {
342     config.force_focus_wrapping = eval_boolstr(value);
343 }
344
345 CFGFUN(workspace_back_and_forth, const char *value) {
346     config.workspace_auto_back_and_forth = eval_boolstr(value);
347 }
348
349 CFGFUN(fake_outputs, const char *outputs) {
350     config.fake_outputs = sstrdup(outputs);
351 }
352
353 CFGFUN(force_display_urgency_hint, const long duration_ms) {
354     config.workspace_urgency_timer = duration_ms / 1000.0;
355 }
356
357 CFGFUN(delay_exit_on_zero_displays, const long duration_ms) {
358     config.zero_disp_exit_timer_ms = duration_ms;
359 }
360
361 CFGFUN(focus_on_window_activation, const char *mode) {
362     if (strcmp(mode, "smart") == 0)
363         config.focus_on_window_activation = FOWA_SMART;
364     else if (strcmp(mode, "urgent") == 0)
365         config.focus_on_window_activation = FOWA_URGENT;
366     else if (strcmp(mode, "focus") == 0)
367         config.focus_on_window_activation = FOWA_FOCUS;
368     else if (strcmp(mode, "none") == 0)
369         config.focus_on_window_activation = FOWA_NONE;
370     else {
371         ELOG("Unknown focus_on_window_activation mode \"%s\", ignoring it.\n", mode);
372         return;
373     }
374
375     DLOG("Set new focus_on_window_activation mode = %i", config.focus_on_window_activation);
376 }
377
378 CFGFUN(show_marks, const char *value) {
379     config.show_marks = eval_boolstr(value);
380 }
381
382 CFGFUN(workspace, const char *workspace, const char *output) {
383     DLOG("Assigning workspace \"%s\" to output \"%s\"\n", workspace, output);
384     /* Check for earlier assignments of the same workspace so that we
385      * don’t have assignments of a single workspace to different
386      * outputs */
387     struct Workspace_Assignment *assignment;
388     bool duplicate = false;
389     TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) {
390         if (strcasecmp(assignment->name, workspace) == 0) {
391             ELOG("You have a duplicate workspace assignment for workspace \"%s\"\n",
392                  workspace);
393             assignment->output = sstrdup(output);
394             duplicate = true;
395         }
396     }
397     if (!duplicate) {
398         assignment = scalloc(sizeof(struct Workspace_Assignment));
399         assignment->name = sstrdup(workspace);
400         assignment->output = sstrdup(output);
401         TAILQ_INSERT_TAIL(&ws_assignments, assignment, ws_assignments);
402     }
403 }
404
405 CFGFUN(ipc_socket, const char *path) {
406     config.ipc_socket_path = sstrdup(path);
407 }
408
409 CFGFUN(restart_state, const char *path) {
410     config.restart_state_path = sstrdup(path);
411 }
412
413 CFGFUN(popup_during_fullscreen, const char *value) {
414     if (strcmp(value, "ignore") == 0) {
415         config.popup_during_fullscreen = PDF_IGNORE;
416     } else if (strcmp(value, "leave_fullscreen") == 0) {
417         config.popup_during_fullscreen = PDF_LEAVE_FULLSCREEN;
418     } else {
419         config.popup_during_fullscreen = PDF_SMART;
420     }
421 }
422
423 CFGFUN(color_single, const char *colorclass, const char *color) {
424     /* used for client.background only currently */
425     config.client.background = get_colorpixel(color);
426 }
427
428 CFGFUN(color, const char *colorclass, const char *border, const char *background, const char *text, const char *indicator) {
429 #define APPLY_COLORS(classname)                                                \
430     do {                                                                       \
431         if (strcmp(colorclass, "client." #classname) == 0) {                   \
432             config.client.classname.border = get_colorpixel(border);           \
433             config.client.classname.background = get_colorpixel(background);   \
434             config.client.classname.text = get_colorpixel(text);               \
435             if (indicator != NULL) {                                           \
436                 config.client.classname.indicator = get_colorpixel(indicator); \
437             }                                                                  \
438         }                                                                      \
439     } while (0)
440
441     APPLY_COLORS(focused_inactive);
442     APPLY_COLORS(focused);
443     APPLY_COLORS(unfocused);
444     APPLY_COLORS(urgent);
445     APPLY_COLORS(placeholder);
446
447 #undef APPLY_COLORS
448 }
449
450 CFGFUN(assign, const char *workspace) {
451     if (match_is_empty(current_match)) {
452         ELOG("Match is empty, ignoring this assignment\n");
453         return;
454     }
455     DLOG("new assignment, using above criteria, to workspace %s\n", workspace);
456     Assignment *assignment = scalloc(sizeof(Assignment));
457     match_copy(&(assignment->match), current_match);
458     assignment->type = A_TO_WORKSPACE;
459     assignment->dest.workspace = sstrdup(workspace);
460     TAILQ_INSERT_TAIL(&assignments, assignment, assignments);
461 }
462
463 CFGFUN(no_focus) {
464     if (match_is_empty(current_match)) {
465         ELOG("Match is empty, ignoring this assignment\n");
466         return;
467     }
468
469     DLOG("new assignment, using above criteria, to ignore focus on manage");
470     Assignment *assignment = scalloc(sizeof(Assignment));
471     match_copy(&(assignment->match), current_match);
472     assignment->type = A_NO_FOCUS;
473     TAILQ_INSERT_TAIL(&assignments, assignment, assignments);
474 }
475
476 /*******************************************************************************
477  * Bar configuration (i3bar)
478  ******************************************************************************/
479
480 static Barconfig current_bar;
481
482 CFGFUN(bar_font, const char *font) {
483     FREE(current_bar.font);
484     current_bar.font = sstrdup(font);
485 }
486
487 CFGFUN(bar_separator_symbol, const char *separator) {
488     FREE(current_bar.separator_symbol);
489     current_bar.separator_symbol = sstrdup(separator);
490 }
491
492 CFGFUN(bar_mode, const char *mode) {
493     current_bar.mode = (strcmp(mode, "dock") == 0 ? M_DOCK : (strcmp(mode, "hide") == 0 ? M_HIDE : M_INVISIBLE));
494 }
495
496 CFGFUN(bar_hidden_state, const char *hidden_state) {
497     current_bar.hidden_state = (strcmp(hidden_state, "hide") == 0 ? S_HIDE : S_SHOW);
498 }
499
500 CFGFUN(bar_id, const char *bar_id) {
501     current_bar.id = sstrdup(bar_id);
502 }
503
504 CFGFUN(bar_output, const char *output) {
505     int new_outputs = current_bar.num_outputs + 1;
506     current_bar.outputs = srealloc(current_bar.outputs, sizeof(char *) * new_outputs);
507     current_bar.outputs[current_bar.num_outputs] = sstrdup(output);
508     current_bar.num_outputs = new_outputs;
509 }
510
511 CFGFUN(bar_verbose, const char *verbose) {
512     current_bar.verbose = eval_boolstr(verbose);
513 }
514
515 CFGFUN(bar_modifier, const char *modifier) {
516     if (strcmp(modifier, "Mod1") == 0)
517         current_bar.modifier = M_MOD1;
518     else if (strcmp(modifier, "Mod2") == 0)
519         current_bar.modifier = M_MOD2;
520     else if (strcmp(modifier, "Mod3") == 0)
521         current_bar.modifier = M_MOD3;
522     else if (strcmp(modifier, "Mod4") == 0)
523         current_bar.modifier = M_MOD4;
524     else if (strcmp(modifier, "Mod5") == 0)
525         current_bar.modifier = M_MOD5;
526     else if (strcmp(modifier, "Control") == 0 ||
527              strcmp(modifier, "Ctrl") == 0)
528         current_bar.modifier = M_CONTROL;
529     else if (strcmp(modifier, "Shift") == 0)
530         current_bar.modifier = M_SHIFT;
531 }
532
533 static void bar_configure_binding(const char *button, const char *command) {
534     if (strncasecmp(button, "button", strlen("button")) != 0) {
535         ELOG("Bindings for a bar can only be mouse bindings, not \"%s\", ignoring.\n", button);
536         return;
537     }
538
539     int input_code = atoi(button + strlen("button"));
540     if (input_code < 1) {
541         ELOG("Button \"%s\" does not seem to be in format 'buttonX'.\n", button);
542         return;
543     }
544
545     struct Barbinding *current;
546     TAILQ_FOREACH(current, &(current_bar.bar_bindings), bindings) {
547         if (current->input_code == input_code) {
548             ELOG("command for button %s was already specified, ignoring.\n", button);
549             return;
550         }
551     }
552
553     struct Barbinding *new_binding = scalloc(sizeof(struct Barbinding));
554     new_binding->input_code = input_code;
555     new_binding->command = sstrdup(command);
556     TAILQ_INSERT_TAIL(&(current_bar.bar_bindings), new_binding, bindings);
557 }
558
559 CFGFUN(bar_wheel_up_cmd, const char *command) {
560     ELOG("'wheel_up_cmd' is deprecated. Please us 'bindsym button4 %s' instead.\n", command);
561     bar_configure_binding("button4", command);
562 }
563
564 CFGFUN(bar_wheel_down_cmd, const char *command) {
565     ELOG("'wheel_down_cmd' is deprecated. Please us 'bindsym button5 %s' instead.\n", command);
566     bar_configure_binding("button5", command);
567 }
568
569 CFGFUN(bar_bindsym, const char *button, const char *command) {
570     bar_configure_binding(button, command);
571 }
572
573 CFGFUN(bar_position, const char *position) {
574     current_bar.position = (strcmp(position, "top") == 0 ? P_TOP : P_BOTTOM);
575 }
576
577 CFGFUN(bar_i3bar_command, const char *i3bar_command) {
578     FREE(current_bar.i3bar_command);
579     current_bar.i3bar_command = sstrdup(i3bar_command);
580 }
581
582 CFGFUN(bar_color, const char *colorclass, const char *border, const char *background, const char *text) {
583 #define APPLY_COLORS(classname)                                          \
584     do {                                                                 \
585         if (strcmp(colorclass, #classname) == 0) {                       \
586             if (text != NULL) {                                          \
587                 /* New syntax: border, background, text */               \
588                 current_bar.colors.classname##_border = sstrdup(border); \
589                 current_bar.colors.classname##_bg = sstrdup(background); \
590                 current_bar.colors.classname##_text = sstrdup(text);     \
591             } else {                                                     \
592                 /* Old syntax: text, background */                       \
593                 current_bar.colors.classname##_bg = sstrdup(background); \
594                 current_bar.colors.classname##_text = sstrdup(border);   \
595             }                                                            \
596         }                                                                \
597     } while (0)
598
599     APPLY_COLORS(focused_workspace);
600     APPLY_COLORS(active_workspace);
601     APPLY_COLORS(inactive_workspace);
602     APPLY_COLORS(urgent_workspace);
603     APPLY_COLORS(binding_mode);
604
605 #undef APPLY_COLORS
606 }
607
608 CFGFUN(bar_socket_path, const char *socket_path) {
609     FREE(current_bar.socket_path);
610     current_bar.socket_path = sstrdup(socket_path);
611 }
612
613 CFGFUN(bar_tray_output, const char *output) {
614     FREE(current_bar.tray_output);
615     current_bar.tray_output = sstrdup(output);
616 }
617
618 CFGFUN(bar_tray_padding, const long padding_px) {
619     current_bar.tray_padding = padding_px;
620 }
621
622 CFGFUN(bar_color_single, const char *colorclass, const char *color) {
623     if (strcmp(colorclass, "background") == 0)
624         current_bar.colors.background = sstrdup(color);
625     else if (strcmp(colorclass, "separator") == 0)
626         current_bar.colors.separator = sstrdup(color);
627     else
628         current_bar.colors.statusline = sstrdup(color);
629 }
630
631 CFGFUN(bar_status_command, const char *command) {
632     FREE(current_bar.status_command);
633     current_bar.status_command = sstrdup(command);
634 }
635
636 CFGFUN(bar_binding_mode_indicator, const char *value) {
637     current_bar.hide_binding_mode_indicator = !eval_boolstr(value);
638 }
639
640 CFGFUN(bar_workspace_buttons, const char *value) {
641     current_bar.hide_workspace_buttons = !eval_boolstr(value);
642 }
643
644 CFGFUN(bar_strip_workspace_numbers, const char *value) {
645     current_bar.strip_workspace_numbers = eval_boolstr(value);
646 }
647
648 CFGFUN(bar_start) {
649     TAILQ_INIT(&(current_bar.bar_bindings));
650     current_bar.tray_padding = 2;
651 }
652
653 CFGFUN(bar_finish) {
654     DLOG("\t new bar configuration finished, saving.\n");
655     /* Generate a unique ID for this bar if not already configured */
656     if (!current_bar.id)
657         sasprintf(&current_bar.id, "bar-%d", config.number_barconfigs);
658
659     config.number_barconfigs++;
660
661     /* If no font was explicitly set, we use the i3 font as default */
662     if (!current_bar.font && font_pattern)
663         current_bar.font = sstrdup(font_pattern);
664
665     /* Copy the current (static) structure into a dynamically allocated
666      * one, then cleanup our static one. */
667     Barconfig *bar_config = scalloc(sizeof(Barconfig));
668     memcpy(bar_config, &current_bar, sizeof(Barconfig));
669     TAILQ_INSERT_TAIL(&barconfigs, bar_config, configs);
670
671     memset(&current_bar, '\0', sizeof(Barconfig));
672 }