3 * vim:ts=4:sw=4:expandtab
14 static pid_t configerror_pid = -1;
16 static Match current_match;
18 typedef struct yy_buffer_state *YY_BUFFER_STATE;
19 extern int yylex(struct context *context);
20 extern int yyparse(void);
21 extern int yylex_destroy(void);
23 YY_BUFFER_STATE yy_scan_string(const char *);
25 static struct bindings_head *current_bindings;
26 static struct context *context;
28 /* We don’t need yydebug for now, as we got decent error messages using
29 * yyerror(). Should you ever want to extend the parser, it might be handy
30 * to just comment it in again, so it stays here. */
33 void yyerror(const char *error_message) {
34 context->has_errors = true;
37 ELOG("CONFIG: %s\n", error_message);
38 ELOG("CONFIG: in file \"%s\", line %d:\n",
39 context->filename, context->line_number);
40 ELOG("CONFIG: %s\n", context->line_copy);
41 char buffer[context->last_column+1];
42 buffer[context->last_column] = '\0';
43 for (int c = 1; c <= context->last_column; c++)
44 buffer[c-1] = (c >= context->first_column ? '^' : ' ');
45 ELOG("CONFIG: %s\n", buffer);
54 * Goes through each line of buf (separated by \n) and checks for statements /
55 * commands which only occur in i3 v4 configuration files. If it finds any, it
56 * returns version 4, otherwise it returns version 3.
59 static int detect_version(char *buf) {
62 while (*walk != '\0') {
68 /* check for some v4-only statements */
69 if (strncasecmp(line, "bindcode", strlen("bindcode")) == 0 ||
70 strncasecmp(line, "force_focus_wrapping", strlen("force_focus_wrapping")) == 0 ||
71 strncasecmp(line, "# i3 config file (v4)", strlen("# i3 config file (v4)")) == 0 ||
72 strncasecmp(line, "workspace_layout", strlen("workspace_layout")) == 0) {
73 printf("deciding for version 4 due to this line: %.*s\n", (int)(walk-line), line);
77 /* if this is a bind statement, we can check the command */
78 if (strncasecmp(line, "bind", strlen("bind")) == 0) {
79 char *bind = strchr(line, ' ');
82 while ((*bind == ' ' || *bind == '\t') && *bind != '\0')
86 if ((bind = strchr(bind, ' ')) == NULL)
88 while ((*bind == ' ' || *bind == '\t') && *bind != '\0')
92 if (strncasecmp(bind, "layout", strlen("layout")) == 0 ||
93 strncasecmp(bind, "floating", strlen("floating")) == 0 ||
94 strncasecmp(bind, "workspace", strlen("workspace")) == 0 ||
95 strncasecmp(bind, "focus left", strlen("focus left")) == 0 ||
96 strncasecmp(bind, "focus right", strlen("focus right")) == 0 ||
97 strncasecmp(bind, "focus up", strlen("focus up")) == 0 ||
98 strncasecmp(bind, "focus down", strlen("focus down")) == 0 ||
99 strncasecmp(bind, "border normal", strlen("border normal")) == 0 ||
100 strncasecmp(bind, "border 1pixel", strlen("border 1pixel")) == 0 ||
101 strncasecmp(bind, "border borderless", strlen("border borderless")) == 0) {
102 printf("deciding for version 4 due to this line: %.*s\n", (int)(walk-line), line);
108 /* advance to the next line */
117 * Calls i3-migrate-config-to-v4 to migrate a configuration file (input
120 * Returns the converted config file or NULL if there was an error (for
121 * example the script could not be found in $PATH or the i3 executable’s
125 static char *migrate_config(char *input, off_t size) {
129 if (pipe(writepipe) != 0 ||
130 pipe(readpipe) != 0) {
131 warn("migrate_config: Could not create pipes");
137 warn("Could not fork()");
143 /* close writing end of writepipe, connect reading side to stdin */
145 dup2(writepipe[0], 0);
147 /* close reading end of readpipe, connect writing side to stdout */
149 dup2(readpipe[1], 1);
151 static char *argv[] = {
152 NULL, /* will be replaced by the executable path */
155 exec_i3_utility("i3-migrate-config-to-v4", argv);
160 /* close reading end of the writepipe (connected to the script’s stdin) */
163 /* write the whole config file to the pipe, the script will read everything
167 while (written < size) {
168 if ((ret = write(writepipe[1], input + written, size - written)) < 0) {
169 warn("Could not write to pipe");
176 /* close writing end of the readpipe (connected to the script’s stdout) */
179 /* read the script’s output */
180 int conv_size = 65535;
181 char *converted = malloc(conv_size);
184 if (read_bytes == conv_size) {
186 converted = realloc(converted, conv_size);
188 ret = read(readpipe[0], converted + read_bytes, conv_size - read_bytes);
190 warn("Cannot read from pipe");
197 /* get the returncode */
200 if (!WIFEXITED(status)) {
201 fprintf(stderr, "Child did not terminate normally, using old config file (will lead to broken behaviour)\n");
205 int returncode = WEXITSTATUS(status);
206 if (returncode != 0) {
207 fprintf(stderr, "Migration process exit code was != 0\n");
208 if (returncode == 2) {
209 fprintf(stderr, "could not start the migration script\n");
210 /* TODO: script was not found. tell the user to fix his system or create a v4 config */
211 } else if (returncode == 1) {
212 fprintf(stderr, "This already was a v4 config. Please add the following line to your config file:\n");
213 fprintf(stderr, "# i3 config file (v4)\n");
214 /* TODO: nag the user with a message to include a hint for i3 in his config file */
223 * Handler which will be called when we get a SIGCHLD for the nagbar, meaning
224 * it exited (or could not be started, depending on the exit code).
227 static void nagbar_exited(EV_P_ ev_child *watcher, int revents) {
228 ev_child_stop(EV_A_ watcher);
229 if (!WIFEXITED(watcher->rstatus)) {
230 fprintf(stderr, "ERROR: i3-nagbar did not exit normally.\n");
234 int exitcode = WEXITSTATUS(watcher->rstatus);
235 printf("i3-nagbar process exited with status %d\n", exitcode);
237 fprintf(stderr, "ERROR: i3-nagbar could not be found. Is it correctly installed on your system?\n");
240 configerror_pid = -1;
244 * Starts an i3-nagbar process which alerts the user that his configuration
245 * file contains one or more errors. Also offers two buttons: One to launch an
246 * $EDITOR on the config file and another one to launch a $PAGER on the error
250 static void start_configerror_nagbar(const char *config_path) {
251 fprintf(stderr, "Would start i3-nagscreen now\n");
252 configerror_pid = fork();
253 if (configerror_pid == -1) {
254 warn("Could not fork()");
259 if (configerror_pid == 0) {
262 if (asprintf(&editaction, TERM_EMU " -e sh -c \"${EDITOR:-vi} \"%s\" && i3-msg reload\"", config_path) == -1)
264 if (asprintf(&pageraction, TERM_EMU " -e sh -c \"${PAGER:-less} \"%s\"\"", errorfilename) == -1)
267 NULL, /* will be replaced by the executable path */
269 "You have an error in your i3 config file!",
273 (errorfilename ? "-b" : NULL),
278 exec_i3_utility("i3-nagbar", argv);
282 /* install a child watcher */
283 ev_child *child = smalloc(sizeof(ev_child));
284 ev_child_init(child, &nagbar_exited, configerror_pid, 0);
285 ev_child_start(main_loop, child);
289 * Kills the configerror i3-nagbar process, if any.
291 * Called when reloading/restarting.
293 * If wait_for_it is set (restarting), this function will waitpid(), otherwise,
294 * ev is assumed to handle it (reloading).
297 void kill_configerror_nagbar(bool wait_for_it) {
298 if (configerror_pid == -1)
301 if (kill(configerror_pid, SIGTERM) == -1)
302 warn("kill(configerror_nagbar) failed");
307 /* When restarting, we don’t enter the ev main loop anymore and after the
308 * exec(), our old pid is no longer watched. So, ev won’t handle SIGCHLD
309 * for us and we would end up with a <defunct> process. Therefore we
311 waitpid(configerror_pid, NULL, 0);
314 void parse_file(const char *f) {
315 SLIST_HEAD(variables_head, Variable) variables = SLIST_HEAD_INITIALIZER(&variables);
316 int fd, ret, read_bytes = 0;
320 char buffer[1026], key[512], value[512];
322 if ((fd = open(f, O_RDONLY)) == -1)
323 die("Could not open configuration file: %s\n", strerror(errno));
325 if (fstat(fd, &stbuf) == -1)
326 die("Could not fstat file: %s\n", strerror(errno));
328 buf = scalloc((stbuf.st_size + 1) * sizeof(char));
329 while (read_bytes < stbuf.st_size) {
330 if ((ret = read(fd, buf + read_bytes, (stbuf.st_size - read_bytes))) < 0)
331 die("Could not read(): %s\n", strerror(errno));
335 if (lseek(fd, 0, SEEK_SET) == (off_t)-1)
336 die("Could not lseek: %s\n", strerror(errno));
338 if ((fstr = fdopen(fd, "r")) == NULL)
339 die("Could not fdopen: %s\n", strerror(errno));
341 while (!feof(fstr)) {
342 if (fgets(buffer, 1024, fstr) == NULL) {
345 die("Could not read configuration file\n");
348 /* sscanf implicitly strips whitespace. Also, we skip comments and empty lines. */
349 if (sscanf(buffer, "%s %[^\n]", key, value) < 1 ||
350 key[0] == '#' || strlen(key) < 3)
353 if (strcasecmp(key, "set") == 0) {
354 if (value[0] != '$') {
355 ELOG("Malformed variable assignment, name has to start with $\n");
359 /* get key/value for this variable */
360 char *v_key = value, *v_value;
361 if ((v_value = strstr(value, " ")) == NULL &&
362 (v_value = strstr(value, "\t")) == NULL) {
363 ELOG("Malformed variable assignment, need a value\n");
369 struct Variable *new = scalloc(sizeof(struct Variable));
370 new->key = sstrdup(v_key);
371 new->value = sstrdup(v_value);
372 SLIST_INSERT_HEAD(&variables, new, variables);
373 DLOG("Got new variable %s = %s\n", v_key, v_value);
379 /* For every custom variable, see how often it occurs in the file and
380 * how much extra bytes it requires when replaced. */
381 struct Variable *current, *nearest;
383 /* We need to copy the buffer because we need to invalidate the
384 * variables (otherwise we will count them twice, which is bad when
385 * 'extra' is negative) */
386 char *bufcopy = sstrdup(buf);
387 SLIST_FOREACH(current, &variables, variables) {
388 int extra = (strlen(current->value) - strlen(current->key));
391 (next = strcasestr(bufcopy + (next - bufcopy), current->key)) != NULL;
392 next += strlen(current->key)) {
394 extra_bytes += extra;
399 /* Then, allocate a new buffer and copy the file over to the new one,
400 * but replace occurences of our variables */
401 char *walk = buf, *destwalk;
402 char *new = smalloc((stbuf.st_size + extra_bytes + 1) * sizeof(char));
404 while (walk < (buf + stbuf.st_size)) {
405 /* Find the next variable */
406 SLIST_FOREACH(current, &variables, variables)
407 current->next_match = strcasestr(walk, current->key);
409 int distance = stbuf.st_size;
410 SLIST_FOREACH(current, &variables, variables) {
411 if (current->next_match == NULL)
413 if ((current->next_match - walk) < distance) {
414 distance = (current->next_match - walk);
418 if (nearest == NULL) {
419 /* If there are no more variables, we just copy the rest */
420 strncpy(destwalk, walk, (buf + stbuf.st_size) - walk);
421 destwalk += (buf + stbuf.st_size) - walk;
425 /* Copy until the next variable, then copy its value */
426 strncpy(destwalk, walk, distance);
427 strncpy(destwalk + distance, nearest->value, strlen(nearest->value));
428 walk += distance + strlen(nearest->key);
429 destwalk += distance + strlen(nearest->value);
433 /* analyze the string to find out whether this is an old config file (3.x)
434 * or a new config file (4.x). If it’s old, we run the converter script. */
435 int version = detect_version(buf);
437 /* We need to convert this v3 configuration */
438 char *converted = migrate_config(new, stbuf.st_size);
439 if (converted != NULL) {
441 printf("****************************************************************\n");
442 printf("NOTE: Automatically converted configuration file from v3 to v4.\n");
444 printf("Please convert your config file to v4. You can use this command:\n");
445 printf(" mv %s %s.O\n", f, f);
446 printf(" i3-migrate-config-to-v4 %s.O > %s\n", f, f);
447 printf("****************************************************************\n");
453 printf("**********************************************************************\n");
454 printf("ERROR: Could not convert config file. Maybe i3-migrate-config-to-v4\n");
455 printf("was not correctly installed on your system?\n");
456 printf("**********************************************************************\n");
461 /* now lex/parse it */
464 context = scalloc(sizeof(struct context));
465 context->filename = f;
467 if (yyparse() != 0) {
468 fprintf(stderr, "Could not parse configfile\n");
472 if (context->has_errors) {
473 start_configerror_nagbar(f);
477 FREE(context->line_copy);
482 while (!SLIST_EMPTY(&variables)) {
483 current = SLIST_FIRST(&variables);
485 FREE(current->value);
486 SLIST_REMOVE_HEAD(&variables, variables);
494 %lex-param { struct context *context }
499 uint32_t *single_color;
500 struct Colortriple *color;
502 struct Binding *binding;
505 %token <number> NUMBER "<number>"
506 %token <string> WORD "<word>"
507 %token <string> STR "<string>"
508 %token <string> STR_NG "<string (non-greedy)>"
509 %token <string> HEX "<hex>"
510 %token <string> OUTPUT "<RandR output>"
513 %token TOKCOMMENT "<comment>"
514 %token TOKFONT "font"
515 %token TOKBINDSYM "bindsym"
516 %token <number> MODIFIER "<modifier>"
517 %token TOKCONTROL "control"
518 %token TOKSHIFT "shift"
519 %token TOKFLOATING_MODIFIER "floating_modifier"
520 %token <string> QUOTEDSTRING "<quoted string>"
521 %token TOKWORKSPACE "workspace"
522 %token TOKOUTPUT "output"
523 %token TOKASSIGN "assign"
525 %token TOKIPCSOCKET "ipc_socket"
526 %token TOKRESTARTSTATE "restart_state"
527 %token TOKEXEC "exec"
528 %token TOKEXEC_ALWAYS "exec_always"
529 %token <single_color> TOKSINGLECOLOR
530 %token <color> TOKCOLOR
532 %token TOKMODE "mode"
533 %token TOK_ORIENTATION "default_orientation"
534 %token TOK_HORIZ "horizontal"
535 %token TOK_VERT "vertical"
536 %token TOK_AUTO "auto"
537 %token TOK_WORKSPACE_LAYOUT "workspace_layout"
538 %token TOKNEWWINDOW "new_window"
539 %token TOK_NORMAL "normal"
540 %token TOK_NONE "none"
541 %token TOK_1PIXEL "1pixel"
542 %token TOKFOCUSFOLLOWSMOUSE "focus_follows_mouse"
543 %token TOK_FORCE_FOCUS_WRAPPING "force_focus_wrapping"
544 %token TOKWORKSPACEBAR "workspace_bar"
545 %token TOK_DEFAULT "default"
546 %token TOK_STACKING "stacking"
547 %token TOK_TABBED "tabbed"
548 %token <number> TOKSTACKLIMIT "stack-limit"
549 %token TOK_POPUP_DURING_FULLSCREEN "popup_during_fullscreen"
550 %token TOK_IGNORE "ignore"
551 %token TOK_LEAVE_FULLSCREEN "leave_fullscreen"
552 %token TOK_FOR_WINDOW "for_window"
554 %token TOK_MARK "mark"
555 %token TOK_CLASS "class"
556 %token TOK_INSTANCE "instance"
558 %token TOK_CON_ID "con_id"
559 %token TOK_TITLE "title"
561 %type <binding> binding
562 %type <binding> bindcode
563 %type <binding> bindsym
564 %type <number> binding_modifiers
565 %type <number> binding_modifier
566 %type <number> direction
567 %type <number> layout_mode
568 %type <number> border_style
569 %type <number> new_window
570 %type <number> colorpixel
572 %type <number> popup_setting
573 %type <string> command
574 %type <string> word_or_number
575 %type <string> optional_workspace_name
576 %type <string> workspace_name
577 %type <string> window_class
594 | focus_follows_mouse
595 | force_focus_wrapping
608 | popup_during_fullscreen
622 TAILQ_INSERT_TAIL(bindings, $1, bindings);
627 TOKBINDCODE bindcode { $$ = $2; }
628 | TOKBINDSYM bindsym { $$ = $2; }
632 binding_modifiers NUMBER command
634 printf("\tFound keycode binding mod%d with key %d and command %s\n", $1, $2, $3);
635 Binding *new = scalloc(sizeof(Binding));
646 binding_modifiers word_or_number command
648 printf("\tFound keysym binding mod%d with key %s and command %s\n", $1, $2, $3);
649 Binding *new = scalloc(sizeof(Binding));
660 TOK_FOR_WINDOW match command
662 if (match_is_empty(¤t_match)) {
663 ELOG("Match is empty, ignoring this for_window statement\n");
666 printf("\t should execute command %s for the criteria mentioned above\n", $3);
667 Assignment *assignment = scalloc(sizeof(Assignment));
668 assignment->type = A_COMMAND;
669 assignment->match = current_match;
670 assignment->dest.command = $3;
671 TAILQ_INSERT_TAIL(&assignments, assignment, assignments);
676 | matchstart criteria matchend
678 printf("match parsed\n");
686 match_init(¤t_match);
693 printf("match specification finished\n");
705 printf("criteria: class = %s\n", $3);
706 current_match.class = $3;
708 | TOK_INSTANCE '=' STR
710 printf("criteria: instance = %s\n", $3);
711 current_match.instance = $3;
715 printf("criteria: id = %s\n", $3);
717 long parsed = strtol($3, &end, 10);
718 if (parsed == LONG_MIN ||
719 parsed == LONG_MAX ||
721 (end && *end != '\0')) {
722 ELOG("Could not parse con id \"%s\"\n", $3);
724 current_match.con_id = (Con*)parsed;
725 printf("id as int = %p\n", current_match.con_id);
730 printf("criteria: window id = %s\n", $3);
732 long parsed = strtol($3, &end, 10);
733 if (parsed == LONG_MIN ||
734 parsed == LONG_MAX ||
736 (end && *end != '\0')) {
737 ELOG("Could not parse window id \"%s\"\n", $3);
739 current_match.id = parsed;
740 printf("window id as int = %d\n", current_match.id);
745 printf("criteria: mark = %s\n", $3);
746 current_match.mark = $3;
750 printf("criteria: title = %s\n", $3);
751 current_match.title = $3;
761 asprintf(&$$, "%d", $1);
766 TOKMODE QUOTEDSTRING '{' modelines '}'
768 if (strcasecmp($2, "default") == 0) {
769 printf("You cannot use the name \"default\" for your mode\n");
772 printf("\t now in mode %s\n", $2);
773 printf("\t current bindings = %p\n", current_bindings);
775 TAILQ_FOREACH(binding, current_bindings, bindings) {
776 printf("got binding on mods %d, keycode %d, symbol %s, command %s\n",
777 binding->mods, binding->keycode, binding->symbol, binding->command);
780 struct Mode *mode = scalloc(sizeof(struct Mode));
782 mode->bindings = current_bindings;
783 current_bindings = NULL;
784 SLIST_INSERT_HEAD(&modes, mode, modes);
798 if (current_bindings == NULL) {
799 current_bindings = scalloc(sizeof(struct bindings_head));
800 TAILQ_INIT(current_bindings);
803 TAILQ_INSERT_TAIL(current_bindings, $1, bindings);
808 TOKFLOATING_MODIFIER binding_modifiers
810 DLOG("floating modifier = %d\n", $2);
811 config.floating_modifier = $2;
816 TOK_ORIENTATION direction
818 DLOG("New containers should start with split direction %d\n", $2);
819 config.default_orientation = $2;
824 TOK_HORIZ { $$ = HORIZ; }
825 | TOK_VERT { $$ = VERT; }
826 | TOK_AUTO { $$ = NO_ORIENTATION; }
830 TOK_WORKSPACE_LAYOUT layout_mode
832 DLOG("new containers will be in mode %d\n", $2);
833 config.default_layout = $2;
836 /* We also need to change the layout of the already existing
837 * workspaces here. Workspaces may exist at this point because
838 * of the other directives which are modifying workspaces
839 * (setting the preferred screen or name). While the workspace
840 * objects are already created, they have never been used.
841 * Thus, the user very likely awaits the default container mode
842 * to trigger in this case, regardless of where it is inside
843 * his configuration file. */
845 TAILQ_FOREACH(ws, workspaces, workspaces) {
846 if (ws->table == NULL)
848 switch_layout_mode(global_conn,
850 config.container_mode);
854 | TOK_WORKSPACE_LAYOUT TOKSTACKLIMIT TOKSTACKLIMIT NUMBER
856 DLOG("stack-limit %d with val %d\n", $3, $4);
857 config.container_stack_limit = $3;
858 config.container_stack_limit_value = $4;
861 /* See the comment above */
863 TAILQ_FOREACH(ws, workspaces, workspaces) {
864 if (ws->table == NULL)
866 Container *con = ws->table[0][0];
867 con->stack_limit = config.container_stack_limit;
868 con->stack_limit_value = config.container_stack_limit_value;
875 TOK_DEFAULT { $$ = L_DEFAULT; }
876 | TOK_STACKING { $$ = L_STACKED; }
877 | TOK_TABBED { $$ = L_TABBED; }
881 TOKNEWWINDOW border_style
883 DLOG("new windows should start with border style %d\n", $2);
884 config.default_border = $2;
889 TOK_NORMAL { $$ = BS_NORMAL; }
890 | TOK_NONE { $$ = BS_NONE; }
891 | TOK_1PIXEL { $$ = BS_1PIXEL; }
901 DLOG("checking word \"%s\"\n", $1);
902 $$ = (strcasecmp($1, "yes") == 0 ||
903 strcasecmp($1, "true") == 0 ||
904 strcasecmp($1, "on") == 0 ||
905 strcasecmp($1, "enable") == 0 ||
906 strcasecmp($1, "active") == 0);
911 TOKFOCUSFOLLOWSMOUSE bool
913 DLOG("focus follows mouse = %d\n", $2);
914 config.disable_focus_follows_mouse = !($2);
918 force_focus_wrapping:
919 TOK_FORCE_FOCUS_WRAPPING bool
921 DLOG("force focus wrapping = %d\n", $2);
922 config.force_focus_wrapping = $2;
929 DLOG("workspace bar = %d\n", $2);
930 config.disable_workspace_bar = !($2);
935 TOKWORKSPACE NUMBER TOKOUTPUT OUTPUT optional_workspace_name
939 DLOG("Invalid workspace assignment, workspace number %d out of range\n", ws_num);
941 char *ws_name = NULL;
943 asprintf(&ws_name, "%d", ws_num);
948 DLOG("Should assign workspace %s to output %s\n", ws_name, $4);
949 /* Check for earlier assignments of the same workspace so that we
950 * don’t have assignments of a single workspace to different
952 struct Workspace_Assignment *assignment;
953 bool duplicate = false;
954 TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) {
955 if (strcasecmp(assignment->name, ws_name) == 0) {
956 ELOG("You have a duplicate workspace assignment for workspace \"%s\"\n",
958 assignment->output = $4;
963 assignment = scalloc(sizeof(struct Workspace_Assignment));
964 assignment->name = ws_name;
965 assignment->output = $4;
966 TAILQ_INSERT_TAIL(&ws_assignments, assignment, ws_assignments);
970 | TOKWORKSPACE NUMBER workspace_name
974 DLOG("Invalid workspace assignment, workspace number %d out of range\n", ws_num);
976 DLOG("workspace name to: %s\n", $3);
978 if ($<string>3 != NULL) {
979 workspace_set_name(workspace_get(ws_num - 1), $<string>3);
987 optional_workspace_name:
988 /* empty */ { $$ = NULL; }
989 | workspace_name { $$ = $1; }
993 QUOTEDSTRING { $$ = $1; }
999 TOKASSIGN window_class STR
1001 printf("assignment of %s to *%s*\n", $2, $3);
1002 char *workspace = $3;
1003 char *criteria = $2;
1005 Assignment *assignment = scalloc(sizeof(Assignment));
1006 Match *match = &(assignment->match);
1009 char *separator = NULL;
1010 if ((separator = strchr(criteria, '/')) != NULL) {
1011 *(separator++) = '\0';
1012 match->title = sstrdup(separator);
1014 if (*criteria != '\0')
1015 match->class = sstrdup(criteria);
1018 printf(" class = %s\n", match->class);
1019 printf(" title = %s\n", match->title);
1021 /* Compatibility with older versions: If the assignment target starts
1022 * with ~, we create the equivalent of:
1024 * for_window [class="foo"] floating enable
1026 if (*workspace == '~') {
1028 if (*workspace == '\0') {
1029 /* This assignment was *only* for floating */
1030 assignment->type = A_COMMAND;
1031 assignment->dest.command = sstrdup("floating enable");
1032 TAILQ_INSERT_TAIL(&assignments, assignment, assignments);
1035 /* Create a new assignment and continue afterwards */
1036 Assignment *floating = scalloc(sizeof(Assignment));
1037 match_copy(&(floating->match), match);
1038 floating->type = A_COMMAND;
1039 floating->dest.command = sstrdup("floating enable");
1040 TAILQ_INSERT_TAIL(&assignments, floating, assignments);
1044 assignment->type = A_TO_WORKSPACE;
1045 assignment->dest.workspace = workspace;
1046 TAILQ_INSERT_TAIL(&assignments, assignment, assignments);
1058 config.ipc_socket_path = $2;
1065 config.restart_state_path = $2;
1072 struct Autostart *new = smalloc(sizeof(struct Autostart));
1074 TAILQ_INSERT_TAIL(&autostarts, new, autostarts);
1081 struct Autostart *new = smalloc(sizeof(struct Autostart));
1083 TAILQ_INSERT_TAIL(&autostarts_always, new, autostarts_always);
1090 ELOG("The terminal option is DEPRECATED and has no effect. "
1091 "Please remove it from your configuration file.\n");
1098 config.font = load_font($2, true);
1099 printf("font %s\n", $2);
1105 TOKSINGLECOLOR colorpixel
1107 uint32_t *dest = $1;
1113 TOKCOLOR colorpixel colorpixel colorpixel
1115 struct Colortriple *dest = $1;
1118 dest->background = $3;
1127 if (asprintf(&hex, "#%s", $2) == -1)
1130 $$ = get_colorpixel(hex);
1137 /* NULL */ { $$ = 0; }
1139 | binding_modifiers '+' binding_modifier { $$ = $1 | $3; }
1140 | binding_modifiers '+' { $$ = $1; }
1144 MODIFIER { $$ = $1; }
1145 | TOKCONTROL { $$ = BIND_CONTROL; }
1146 | TOKSHIFT { $$ = BIND_SHIFT; }
1149 popup_during_fullscreen:
1150 TOK_POPUP_DURING_FULLSCREEN popup_setting
1152 DLOG("popup_during_fullscreen setting: %d\n", $2);
1153 config.popup_during_fullscreen = $2;
1158 TOK_IGNORE { $$ = PDF_IGNORE; }
1159 | TOK_LEAVE_FULLSCREEN { $$ = PDF_LEAVE_FULLSCREEN; }