3 * vim:ts=4:sw=4:expandtab
7 #define I3__FILE__ "cfgparse.y"
16 static pid_t configerror_pid = -1;
18 static Match current_match;
19 static Barconfig current_bar;
20 /* The pattern which was specified by the user, for example -misc-fixed-*. We
21 * store this in a separate variable because in the i3 config struct we just
22 * store the i3Font. */
23 static char *font_pattern;
24 /* The path to the temporary script files used by i3-nagbar. We need to keep
25 * them around to delete the files in the i3-nagbar SIGCHLD handler. */
26 static char *edit_script_path, *pager_script_path;
28 typedef struct yy_buffer_state *YY_BUFFER_STATE;
29 extern int yylex(struct context *context);
30 extern int yyparse(void);
31 extern int yylex_destroy(void);
33 YY_BUFFER_STATE yy_scan_string(const char *);
35 static struct bindings_head *current_bindings;
36 static struct context *context;
38 /* We don’t need yydebug for now, as we got decent error messages using
39 * yyerror(). Should you ever want to extend the parser, it might be handy
40 * to just comment it in again, so it stays here. */
43 void yyerror(const char *error_message) {
44 context->has_errors = true;
47 ELOG("CONFIG: %s\n", error_message);
48 ELOG("CONFIG: in file \"%s\", line %d:\n",
49 context->filename, context->line_number);
50 ELOG("CONFIG: %s\n", context->line_copy);
51 char buffer[context->last_column+1];
52 buffer[context->last_column] = '\0';
53 for (int c = 1; c <= context->last_column; c++)
54 buffer[c-1] = (c >= context->first_column ? '^' : ' ');
55 ELOG("CONFIG: %s\n", buffer);
64 * Goes through each line of buf (separated by \n) and checks for statements /
65 * commands which only occur in i3 v4 configuration files. If it finds any, it
66 * returns version 4, otherwise it returns version 3.
69 static int detect_version(char *buf) {
72 while (*walk != '\0') {
78 /* check for some v4-only statements */
79 if (strncasecmp(line, "bindcode", strlen("bindcode")) == 0 ||
80 strncasecmp(line, "force_focus_wrapping", strlen("force_focus_wrapping")) == 0 ||
81 strncasecmp(line, "# i3 config file (v4)", strlen("# i3 config file (v4)")) == 0 ||
82 strncasecmp(line, "workspace_layout", strlen("workspace_layout")) == 0) {
83 printf("deciding for version 4 due to this line: %.*s\n", (int)(walk-line), line);
87 /* if this is a bind statement, we can check the command */
88 if (strncasecmp(line, "bind", strlen("bind")) == 0) {
89 char *bind = strchr(line, ' ');
92 while ((*bind == ' ' || *bind == '\t') && *bind != '\0')
96 if ((bind = strchr(bind, ' ')) == NULL)
98 while ((*bind == ' ' || *bind == '\t') && *bind != '\0')
102 if (strncasecmp(bind, "layout", strlen("layout")) == 0 ||
103 strncasecmp(bind, "floating", strlen("floating")) == 0 ||
104 strncasecmp(bind, "workspace", strlen("workspace")) == 0 ||
105 strncasecmp(bind, "focus left", strlen("focus left")) == 0 ||
106 strncasecmp(bind, "focus right", strlen("focus right")) == 0 ||
107 strncasecmp(bind, "focus up", strlen("focus up")) == 0 ||
108 strncasecmp(bind, "focus down", strlen("focus down")) == 0 ||
109 strncasecmp(bind, "border normal", strlen("border normal")) == 0 ||
110 strncasecmp(bind, "border 1pixel", strlen("border 1pixel")) == 0 ||
111 strncasecmp(bind, "border borderless", strlen("border borderless")) == 0 ||
112 strncasecmp(bind, "--no-startup-id", strlen("--no-startup-id")) == 0 ||
113 strncasecmp(bind, "bar", strlen("bar")) == 0) {
114 printf("deciding for version 4 due to this line: %.*s\n", (int)(walk-line), line);
120 /* advance to the next line */
129 * Calls i3-migrate-config-to-v4 to migrate a configuration file (input
132 * Returns the converted config file or NULL if there was an error (for
133 * example the script could not be found in $PATH or the i3 executable’s
137 static char *migrate_config(char *input, off_t size) {
141 if (pipe(writepipe) != 0 ||
142 pipe(readpipe) != 0) {
143 warn("migrate_config: Could not create pipes");
149 warn("Could not fork()");
155 /* close writing end of writepipe, connect reading side to stdin */
157 dup2(writepipe[0], 0);
159 /* close reading end of readpipe, connect writing side to stdout */
161 dup2(readpipe[1], 1);
163 static char *argv[] = {
164 NULL, /* will be replaced by the executable path */
167 exec_i3_utility("i3-migrate-config-to-v4", argv);
172 /* close reading end of the writepipe (connected to the script’s stdin) */
175 /* write the whole config file to the pipe, the script will read everything
179 while (written < size) {
180 if ((ret = write(writepipe[1], input + written, size - written)) < 0) {
181 warn("Could not write to pipe");
188 /* close writing end of the readpipe (connected to the script’s stdout) */
191 /* read the script’s output */
192 int conv_size = 65535;
193 char *converted = malloc(conv_size);
196 if (read_bytes == conv_size) {
198 converted = realloc(converted, conv_size);
200 ret = read(readpipe[0], converted + read_bytes, conv_size - read_bytes);
202 warn("Cannot read from pipe");
209 /* get the returncode */
212 if (!WIFEXITED(status)) {
213 fprintf(stderr, "Child did not terminate normally, using old config file (will lead to broken behaviour)\n");
217 int returncode = WEXITSTATUS(status);
218 if (returncode != 0) {
219 fprintf(stderr, "Migration process exit code was != 0\n");
220 if (returncode == 2) {
221 fprintf(stderr, "could not start the migration script\n");
222 /* TODO: script was not found. tell the user to fix his system or create a v4 config */
223 } else if (returncode == 1) {
224 fprintf(stderr, "This already was a v4 config. Please add the following line to your config file:\n");
225 fprintf(stderr, "# i3 config file (v4)\n");
226 /* TODO: nag the user with a message to include a hint for i3 in his config file */
235 * Handler which will be called when we get a SIGCHLD for the nagbar, meaning
236 * it exited (or could not be started, depending on the exit code).
239 static void nagbar_exited(EV_P_ ev_child *watcher, int revents) {
240 ev_child_stop(EV_A_ watcher);
242 if (unlink(edit_script_path) != 0)
243 warn("Could not delete temporary i3-nagbar script %s", edit_script_path);
244 if (unlink(pager_script_path) != 0)
245 warn("Could not delete temporary i3-nagbar script %s", pager_script_path);
247 if (!WIFEXITED(watcher->rstatus)) {
248 fprintf(stderr, "ERROR: i3-nagbar did not exit normally.\n");
252 int exitcode = WEXITSTATUS(watcher->rstatus);
253 printf("i3-nagbar process exited with status %d\n", exitcode);
255 fprintf(stderr, "ERROR: i3-nagbar could not be found. Is it correctly installed on your system?\n");
258 configerror_pid = -1;
261 /* We need ev >= 4 for the following code. Since it is not *that* important (it
262 * only makes sure that there are no i3-nagbar instances left behind) we still
263 * support old systems with libev 3. */
264 #if EV_VERSION_MAJOR >= 4
266 * Cleanup handler. Will be called when i3 exits. Kills i3-nagbar with signal
267 * SIGKILL (9) to make sure there are no left-over i3-nagbar processes.
270 static void nagbar_cleanup(EV_P_ ev_cleanup *watcher, int revent) {
271 if (configerror_pid != -1) {
272 LOG("Sending SIGKILL (9) to i3-nagbar with PID %d\n", configerror_pid);
273 kill(configerror_pid, SIGKILL);
279 * Writes the given command as a shell script to path.
280 * Returns true unless something went wrong.
283 static bool write_nagbar_script(const char *path, const char *command) {
284 int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IXUSR);
286 warn("Could not create temporary script to store the nagbar command");
289 write(fd, "#!/bin/sh\n", strlen("#!/bin/sh\n"));
290 write(fd, command, strlen(command));
296 * Starts an i3-nagbar process which alerts the user that his configuration
297 * file contains one or more errors. Also offers two buttons: One to launch an
298 * $EDITOR on the config file and another one to launch a $PAGER on the error
302 static void start_configerror_nagbar(const char *config_path) {
303 if (only_check_config)
306 fprintf(stderr, "Starting i3-nagbar due to configuration errors\n");
308 /* We need to create a custom script containing our actual command
309 * since not every terminal emulator which is contained in
310 * i3-sensible-terminal supports -e with multiple arguments (and not
311 * all of them support -e with one quoted argument either).
313 * NB: The paths need to be unique, that is, don’t assume users close
314 * their nagbars at any point in time (and they still need to work).
316 edit_script_path = get_process_filename("nagbar-cfgerror-edit");
317 pager_script_path = get_process_filename("nagbar-cfgerror-pager");
319 configerror_pid = fork();
320 if (configerror_pid == -1) {
321 warn("Could not fork()");
326 if (configerror_pid == 0) {
327 char *edit_command, *pager_command;
328 sasprintf(&edit_command, "i3-sensible-editor \"%s\" && i3-msg reload\n", config_path);
329 sasprintf(&pager_command, "i3-sensible-pager \"%s\"\n", errorfilename);
330 if (!write_nagbar_script(edit_script_path, edit_command) ||
331 !write_nagbar_script(pager_script_path, pager_command))
336 sasprintf(&editaction, "i3-sensible-terminal -e \"%s\"", edit_script_path);
337 sasprintf(&pageraction, "i3-sensible-terminal -e \"%s\"", pager_script_path);
339 NULL, /* will be replaced by the executable path */
341 (context->has_errors ? "error" : "warning"),
343 (context->has_errors ?
344 "You have an error in your i3 config file!" :
345 "Your config is outdated. Please fix the warnings to make sure everything works."),
349 (errorfilename ? "-b" : NULL),
350 (context->has_errors ? "show errors" : "show warnings"),
354 exec_i3_utility("i3-nagbar", argv);
358 /* install a child watcher */
359 ev_child *child = smalloc(sizeof(ev_child));
360 ev_child_init(child, &nagbar_exited, configerror_pid, 0);
361 ev_child_start(main_loop, child);
363 /* We need ev >= 4 for the following code. Since it is not *that* important (it
364 * only makes sure that there are no i3-nagbar instances left behind) we still
365 * support old systems with libev 3. */
366 #if EV_VERSION_MAJOR >= 4
367 /* install a cleanup watcher (will be called when i3 exits and i3-nagbar is
369 ev_cleanup *cleanup = smalloc(sizeof(ev_cleanup));
370 ev_cleanup_init(cleanup, nagbar_cleanup);
371 ev_cleanup_start(main_loop, cleanup);
376 * Kills the configerror i3-nagbar process, if any.
378 * Called when reloading/restarting.
380 * If wait_for_it is set (restarting), this function will waitpid(), otherwise,
381 * ev is assumed to handle it (reloading).
384 void kill_configerror_nagbar(bool wait_for_it) {
385 if (configerror_pid == -1)
388 if (kill(configerror_pid, SIGTERM) == -1)
389 warn("kill(configerror_nagbar) failed");
394 /* When restarting, we don’t enter the ev main loop anymore and after the
395 * exec(), our old pid is no longer watched. So, ev won’t handle SIGCHLD
396 * for us and we would end up with a <defunct> process. Therefore we
398 waitpid(configerror_pid, NULL, 0);
402 * Checks for duplicate key bindings (the same keycode or keysym is configured
403 * more than once). If a duplicate binding is found, a message is printed to
404 * stderr and the has_errors variable is set to true, which will start
408 static void check_for_duplicate_bindings(struct context *context) {
409 Binding *bind, *current;
410 TAILQ_FOREACH(current, bindings, bindings) {
411 TAILQ_FOREACH(bind, bindings, bindings) {
412 /* Abort when we reach the current keybinding, only check the
417 /* Check if one is using keysym while the other is using bindsym.
419 /* XXX: It should be checked at a later place (when translating the
420 * keysym to keycodes) if there are any duplicates */
421 if ((bind->symbol == NULL && current->symbol != NULL) ||
422 (bind->symbol != NULL && current->symbol == NULL))
425 /* If bind is NULL, current has to be NULL, too (see above).
426 * If the keycodes differ, it can't be a duplicate. */
427 if (bind->symbol != NULL &&
428 strcasecmp(bind->symbol, current->symbol) != 0)
431 /* Check if the keycodes or modifiers are different. If so, they
432 * can't be duplicate */
433 if (bind->keycode != current->keycode ||
434 bind->mods != current->mods ||
435 bind->release != current->release)
438 context->has_errors = true;
439 if (current->keycode != 0) {
440 ELOG("Duplicate keybinding in config file:\n modmask %d with keycode %d, command \"%s\"\n",
441 current->mods, current->keycode, current->command);
443 ELOG("Duplicate keybinding in config file:\n modmask %d with keysym %s, command \"%s\"\n",
444 current->mods, current->symbol, current->command);
450 static void migrate_i3bar_exec(struct Autostart *exec) {
451 ELOG("**********************************************************************\n");
452 ELOG("IGNORING exec command: %s\n", exec->command);
453 ELOG("It contains \"i3bar\". Since i3 v4.1, i3bar will be automatically started\n");
454 ELOG("for each 'bar' configuration block in your i3 config. Please remove the exec\n");
455 ELOG("line and add the following to your i3 config:\n");
458 ELOG(" status_command i3status\n");
460 ELOG("**********************************************************************\n");
462 /* Generate a dummy bar configuration */
463 Barconfig *bar_config = scalloc(sizeof(Barconfig));
464 /* The hard-coded ID is not a problem. It does not conflict with the
465 * auto-generated bar IDs and having multiple hard-coded IDs is irrelevant
466 * – they all just contain status_command = i3status */
467 bar_config->id = sstrdup("migrate-bar");
468 bar_config->status_command = sstrdup("i3status");
469 TAILQ_INSERT_TAIL(&barconfigs, bar_config, configs);
471 /* Trigger an i3-nagbar */
472 context->has_warnings = true;
475 void parse_file(const char *f) {
476 SLIST_HEAD(variables_head, Variable) variables = SLIST_HEAD_INITIALIZER(&variables);
477 int fd, ret, read_bytes = 0;
481 char buffer[1026], key[512], value[512];
483 if ((fd = open(f, O_RDONLY)) == -1)
484 die("Could not open configuration file: %s\n", strerror(errno));
486 if (fstat(fd, &stbuf) == -1)
487 die("Could not fstat file: %s\n", strerror(errno));
489 buf = scalloc((stbuf.st_size + 1) * sizeof(char));
490 while (read_bytes < stbuf.st_size) {
491 if ((ret = read(fd, buf + read_bytes, (stbuf.st_size - read_bytes))) < 0)
492 die("Could not read(): %s\n", strerror(errno));
496 if (lseek(fd, 0, SEEK_SET) == (off_t)-1)
497 die("Could not lseek: %s\n", strerror(errno));
499 if ((fstr = fdopen(fd, "r")) == NULL)
500 die("Could not fdopen: %s\n", strerror(errno));
502 while (!feof(fstr)) {
503 if (fgets(buffer, 1024, fstr) == NULL) {
506 die("Could not read configuration file\n");
509 /* sscanf implicitly strips whitespace. Also, we skip comments and empty lines. */
510 if (sscanf(buffer, "%s %[^\n]", key, value) < 1 ||
511 key[0] == '#' || strlen(key) < 3)
514 if (strcasecmp(key, "set") == 0) {
515 if (value[0] != '$') {
516 ELOG("Malformed variable assignment, name has to start with $\n");
520 /* get key/value for this variable */
521 char *v_key = value, *v_value;
522 if (strstr(value, " ") == NULL && strstr(value, "\t") == NULL) {
523 ELOG("Malformed variable assignment, need a value\n");
527 if (!(v_value = strstr(value, " ")))
528 v_value = strstr(value, "\t");
531 while (*v_value == '\t' || *v_value == ' ')
534 struct Variable *new = scalloc(sizeof(struct Variable));
535 new->key = sstrdup(v_key);
536 new->value = sstrdup(v_value);
537 SLIST_INSERT_HEAD(&variables, new, variables);
538 DLOG("Got new variable %s = %s\n", v_key, v_value);
544 /* For every custom variable, see how often it occurs in the file and
545 * how much extra bytes it requires when replaced. */
546 struct Variable *current, *nearest;
548 /* We need to copy the buffer because we need to invalidate the
549 * variables (otherwise we will count them twice, which is bad when
550 * 'extra' is negative) */
551 char *bufcopy = sstrdup(buf);
552 SLIST_FOREACH(current, &variables, variables) {
553 int extra = (strlen(current->value) - strlen(current->key));
556 next < (bufcopy + stbuf.st_size) &&
557 (next = strcasestr(next, current->key)) != NULL;
558 next += strlen(current->key)) {
560 extra_bytes += extra;
565 /* Then, allocate a new buffer and copy the file over to the new one,
566 * but replace occurences of our variables */
567 char *walk = buf, *destwalk;
568 char *new = smalloc((stbuf.st_size + extra_bytes + 1) * sizeof(char));
570 while (walk < (buf + stbuf.st_size)) {
571 /* Find the next variable */
572 SLIST_FOREACH(current, &variables, variables)
573 current->next_match = strcasestr(walk, current->key);
575 int distance = stbuf.st_size;
576 SLIST_FOREACH(current, &variables, variables) {
577 if (current->next_match == NULL)
579 if ((current->next_match - walk) < distance) {
580 distance = (current->next_match - walk);
584 if (nearest == NULL) {
585 /* If there are no more variables, we just copy the rest */
586 strncpy(destwalk, walk, (buf + stbuf.st_size) - walk);
587 destwalk += (buf + stbuf.st_size) - walk;
591 /* Copy until the next variable, then copy its value */
592 strncpy(destwalk, walk, distance);
593 strncpy(destwalk + distance, nearest->value, strlen(nearest->value));
594 walk += distance + strlen(nearest->key);
595 destwalk += distance + strlen(nearest->value);
599 /* analyze the string to find out whether this is an old config file (3.x)
600 * or a new config file (4.x). If it’s old, we run the converter script. */
601 int version = detect_version(buf);
603 /* We need to convert this v3 configuration */
604 char *converted = migrate_config(new, stbuf.st_size);
605 if (converted != NULL) {
607 ELOG("****************************************************************\n");
608 ELOG("NOTE: Automatically converted configuration file from v3 to v4.\n");
610 ELOG("Please convert your config file to v4. You can use this command:\n");
611 ELOG(" mv %s %s.O\n", f, f);
612 ELOG(" i3-migrate-config-to-v4 %s.O > %s\n", f, f);
613 ELOG("****************************************************************\n");
619 printf("**********************************************************************\n");
620 printf("ERROR: Could not convert config file. Maybe i3-migrate-config-to-v4\n");
621 printf("was not correctly installed on your system?\n");
622 printf("**********************************************************************\n");
627 /* now lex/parse it */
630 context = scalloc(sizeof(struct context));
631 context->filename = f;
633 if (yyparse() != 0) {
634 fprintf(stderr, "Could not parse configfile\n");
638 check_for_duplicate_bindings(context);
640 /* XXX: The following code will be removed in i3 v4.3 (three releases from
641 * now, as of 2011-10-22) */
642 /* Check for any exec or exec_always lines starting i3bar. We remove these
643 * and add a bar block instead. Additionally, a i3-nagbar warning (not an
644 * error) will be displayed so that users update their config file. */
645 struct Autostart *exec, *next;
646 for (exec = TAILQ_FIRST(&autostarts); exec; ) {
647 next = TAILQ_NEXT(exec, autostarts);
648 if (strstr(exec->command, "i3bar") != NULL) {
649 migrate_i3bar_exec(exec);
650 TAILQ_REMOVE(&autostarts, exec, autostarts);
655 for (exec = TAILQ_FIRST(&autostarts_always); exec; ) {
656 next = TAILQ_NEXT(exec, autostarts_always);
657 if (strstr(exec->command, "i3bar") != NULL) {
658 migrate_i3bar_exec(exec);
659 TAILQ_REMOVE(&autostarts_always, exec, autostarts_always);
664 if (context->has_errors || context->has_warnings) {
665 ELOG("FYI: You are using i3 version " I3_VERSION "\n");
667 ELOG("Please convert your configfile first, then fix any remaining errors (see above).\n");
668 start_configerror_nagbar(f);
672 FREE(context->line_copy);
678 while (!SLIST_EMPTY(&variables)) {
679 current = SLIST_FIRST(&variables);
681 FREE(current->value);
682 SLIST_REMOVE_HEAD(&variables, variables);
690 %lex-param { struct context *context }
695 uint32_t *single_color;
696 struct Colortriple *color;
698 struct Binding *binding;
701 %token <number> NUMBER "<number>"
702 %token <string> WORD "<word>"
703 %token <string> STR "<string>"
704 %token <string> STR_NG "<string (non-greedy)>"
705 %token <string> HEXCOLOR "#<hex>"
706 %token <string> OUTPUT "<RandR output>"
709 %token TOKCOMMENT "<comment>"
710 %token TOKFONT "font"
711 %token TOKBINDSYM "bindsym"
712 %token <number> MODIFIER "<modifier>"
713 %token TOKCONTROL "control"
714 %token TOKSHIFT "shift"
715 %token TOKFLOATING_MODIFIER "floating_modifier"
716 %token TOKFLOATING_MAXIMUM_SIZE "floating_maximum_size"
717 %token TOKFLOATING_MINIMUM_SIZE "floating_minimum_size"
718 %token <string> QUOTEDSTRING "<quoted string>"
719 %token TOKWORKSPACE "workspace"
720 %token TOKOUTPUT "output"
721 %token TOKASSIGN "assign"
723 %token TOKIPCSOCKET "ipc_socket"
724 %token TOKRESTARTSTATE "restart_state"
725 %token TOKEXEC "exec"
726 %token TOKEXEC_ALWAYS "exec_always"
727 %token <single_color> TOKSINGLECOLOR
728 %token <color> TOKCOLOR
730 %token TOKMODE "mode"
732 %token TOK_ORIENTATION "default_orientation"
733 %token TOK_HORIZ "horizontal"
734 %token TOK_VERT "vertical"
735 %token TOK_AUTO "auto"
736 %token TOK_WORKSPACE_LAYOUT "workspace_layout"
737 %token TOKNEWWINDOW "new_window"
738 %token TOKNEWFLOAT "new_float"
739 %token TOK_NORMAL "normal"
740 %token TOK_NONE "none"
741 %token TOK_1PIXEL "1pixel"
742 %token TOK_HIDE_EDGE_BORDERS "hide_edge_borders"
743 %token TOK_BOTH "both"
744 %token TOKFOCUSFOLLOWSMOUSE "focus_follows_mouse"
745 %token TOK_FORCE_FOCUS_WRAPPING "force_focus_wrapping"
746 %token TOK_FORCE_XINERAMA "force_xinerama"
747 %token TOK_FAKE_OUTPUTS "fake_outputs"
748 %token TOK_WORKSPACE_AUTO_BAF "workspace_auto_back_and_forth"
749 %token TOKWORKSPACEBAR "workspace_bar"
750 %token TOK_DEFAULT "default"
751 %token TOK_STACKING "stacking"
752 %token TOK_TABBED "tabbed"
753 %token <number> TOKSTACKLIMIT "stack-limit"
754 %token TOK_POPUP_DURING_FULLSCREEN "popup_during_fullscreen"
755 %token TOK_IGNORE "ignore"
756 %token TOK_LEAVE_FULLSCREEN "leave_fullscreen"
757 %token TOK_FOR_WINDOW "for_window"
759 %token TOK_BAR_OUTPUT "output (bar)"
760 %token TOK_BAR_TRAY_OUTPUT "tray_output"
761 %token TOK_BAR_SOCKET_PATH "socket_path"
762 %token TOK_BAR_MODE "mode (bar)"
763 %token TOK_BAR_HIDE "hide"
764 %token TOK_BAR_DOCK "dock"
765 %token TOK_BAR_MODIFIER "modifier (bar)"
766 %token TOK_BAR_CONTROL "shift (bar)"
767 %token TOK_BAR_SHIFT "control (bar)"
768 %token TOK_BAR_MOD1 "Mod1"
769 %token TOK_BAR_MOD2 "Mod2"
770 %token TOK_BAR_MOD3 "Mod3"
771 %token TOK_BAR_MOD4 "Mod4"
772 %token TOK_BAR_MOD5 "Mod5"
773 %token TOK_BAR_POSITION "position"
774 %token TOK_BAR_BOTTOM "bottom"
775 %token TOK_BAR_TOP "top"
776 %token TOK_BAR_STATUS_COMMAND "status_command"
777 %token TOK_BAR_I3BAR_COMMAND "i3bar_command"
778 %token TOK_BAR_FONT "font (bar)"
779 %token TOK_BAR_WORKSPACE_BUTTONS "workspace_buttons"
780 %token TOK_BAR_VERBOSE "verbose"
781 %token TOK_BAR_COLORS "colors"
782 %token TOK_BAR_COLOR_BACKGROUND "background"
783 %token TOK_BAR_COLOR_STATUSLINE "statusline"
784 %token TOK_BAR_COLOR_FOCUSED_WORKSPACE "focused_workspace"
785 %token TOK_BAR_COLOR_ACTIVE_WORKSPACE "active_workspace"
786 %token TOK_BAR_COLOR_INACTIVE_WORKSPACE "inactive_workspace"
787 %token TOK_BAR_COLOR_URGENT_WORKSPACE "urgent_workspace"
788 %token TOK_NO_STARTUP_ID "--no-startup-id"
789 %token TOK_RELEASE "--release"
791 %token TOK_MARK "mark"
792 %token TOK_CLASS "class"
793 %token TOK_INSTANCE "instance"
794 %token TOK_WINDOW_ROLE "window_role"
796 %token TOK_CON_ID "con_id"
797 %token TOK_TITLE "title"
798 %token TOK_URGENT "urgent"
800 %type <binding> binding
801 %type <binding> bindcode
802 %type <binding> bindsym
803 %type <number> binding_modifiers
804 %type <number> binding_modifier
805 %type <number> direction
806 %type <number> layout_mode
807 %type <number> border_style
808 %type <number> new_window
809 %type <number> hide_edge_borders
810 %type <number> edge_hiding_mode
811 %type <number> new_float
812 %type <number> colorpixel
814 %type <number> popup_setting
815 %type <number> bar_position_position
816 %type <number> bar_mode_mode
817 %type <number> bar_modifier_modifier
818 %type <number> optional_no_startup_id
819 %type <number> optional_release
820 %type <string> command
821 %type <string> word_or_number
822 %type <string> qstring_or_number
823 %type <string> optional_workspace_name
824 %type <string> workspace_name
825 %type <string> window_class
839 | floating_maximum_size
840 | floating_minimum_size
847 | focus_follows_mouse
848 | force_focus_wrapping
851 | workspace_back_and_forth
864 | popup_during_fullscreen
878 TAILQ_INSERT_TAIL(bindings, $1, bindings);
883 TOKBINDCODE bindcode { $$ = $2; }
884 | TOKBINDSYM bindsym { $$ = $2; }
888 optional_release binding_modifiers NUMBER command
890 DLOG("bindcode: release = %d, mod = %d, key = %d, command = %s\n", $1, $2, $3, $4);
891 Binding *new = scalloc(sizeof(Binding));
903 optional_release binding_modifiers word_or_number command
905 DLOG("bindsym: release = %d, mod = %d, key = %s, command = %s\n", $1, $2, $3, $4);
906 Binding *new = scalloc(sizeof(Binding));
918 /* empty */ { $$ = B_UPON_KEYPRESS; }
919 | TOK_RELEASE { $$ = B_UPON_KEYRELEASE; }
923 TOK_FOR_WINDOW match command
925 if (match_is_empty(¤t_match)) {
926 ELOG("Match is empty, ignoring this for_window statement\n");
929 printf("\t should execute command %s for the criteria mentioned above\n", $3);
930 Assignment *assignment = scalloc(sizeof(Assignment));
931 assignment->type = A_COMMAND;
932 assignment->match = current_match;
933 assignment->dest.command = $3;
934 TAILQ_INSERT_TAIL(&assignments, assignment, assignments);
939 | matchstart criteria matchend
941 printf("match parsed\n");
949 match_init(¤t_match);
956 printf("match specification finished\n");
968 printf("criteria: class = %s\n", $3);
969 current_match.class = regex_new($3);
972 | TOK_INSTANCE '=' STR
974 printf("criteria: instance = %s\n", $3);
975 current_match.instance = regex_new($3);
978 | TOK_WINDOW_ROLE '=' STR
980 printf("criteria: window_role = %s\n", $3);
981 current_match.role = regex_new($3);
986 printf("criteria: id = %s\n", $3);
988 long parsed = strtol($3, &end, 10);
989 if (parsed == LONG_MIN ||
990 parsed == LONG_MAX ||
992 (end && *end != '\0')) {
993 ELOG("Could not parse con id \"%s\"\n", $3);
995 current_match.con_id = (Con*)parsed;
996 printf("id as int = %p\n", current_match.con_id);
1001 printf("criteria: window id = %s\n", $3);
1003 long parsed = strtol($3, &end, 10);
1004 if (parsed == LONG_MIN ||
1005 parsed == LONG_MAX ||
1007 (end && *end != '\0')) {
1008 ELOG("Could not parse window id \"%s\"\n", $3);
1010 current_match.id = parsed;
1011 printf("window id as int = %d\n", current_match.id);
1016 printf("criteria: mark = %s\n", $3);
1017 current_match.mark = regex_new($3);
1022 printf("criteria: title = %s\n", $3);
1023 current_match.title = regex_new($3);
1026 | TOK_URGENT '=' STR
1028 printf("criteria: urgent = %s\n", $3);
1029 if (strcasecmp($3, "latest") == 0 ||
1030 strcasecmp($3, "newest") == 0 ||
1031 strcasecmp($3, "recent") == 0 ||
1032 strcasecmp($3, "last") == 0) {
1033 current_match.urgent = U_LATEST;
1034 } else if (strcasecmp($3, "oldest") == 0 ||
1035 strcasecmp($3, "first") == 0) {
1036 current_match.urgent = U_OLDEST;
1044 | NUMBER { sasprintf(&$$, "%d", $1); }
1051 sasprintf(&$$, "%d", $1);
1056 TOKMODE QUOTEDSTRING '{' modelines '}'
1058 if (strcasecmp($2, "default") == 0) {
1059 printf("You cannot use the name \"default\" for your mode\n");
1062 printf("\t now in mode %s\n", $2);
1063 printf("\t current bindings = %p\n", current_bindings);
1065 TAILQ_FOREACH(binding, current_bindings, bindings) {
1066 printf("got binding on mods %d, keycode %d, symbol %s, command %s\n",
1067 binding->mods, binding->keycode, binding->symbol, binding->command);
1070 struct Mode *mode = scalloc(sizeof(struct Mode));
1072 mode->bindings = current_bindings;
1073 current_bindings = NULL;
1074 SLIST_INSERT_HEAD(&modes, mode, modes);
1081 | modelines modeline
1088 if (current_bindings == NULL) {
1089 current_bindings = scalloc(sizeof(struct bindings_head));
1090 TAILQ_INIT(current_bindings);
1093 TAILQ_INSERT_TAIL(current_bindings, $1, bindings);
1098 TOK_BAR '{' barlines '}'
1100 printf("\t new bar configuration finished, saving.\n");
1101 /* Generate a unique ID for this bar */
1102 current_bar.id = sstrdup("bar-XXXXXX");
1103 /* This works similar to mktemp in that it replaces the last six X with
1104 * random letters, but without the restriction that the given buffer
1105 * has to contain a valid path name. */
1106 char *x = current_bar.id + strlen("bar-");
1107 while (*x != '\0') {
1108 *(x++) = (rand() % 26) + 'a';
1111 /* If no font was explicitly set, we use the i3 font as default */
1112 if (!current_bar.font && font_pattern)
1113 current_bar.font = sstrdup(font_pattern);
1115 /* Copy the current (static) structure into a dynamically allocated
1116 * one, then cleanup our static one. */
1117 Barconfig *bar_config = scalloc(sizeof(Barconfig));
1118 memcpy(bar_config, ¤t_bar, sizeof(Barconfig));
1119 TAILQ_INSERT_TAIL(&barconfigs, bar_config, configs);
1121 memset(¤t_bar, '\0', sizeof(Barconfig));
1132 | bar_status_command
1140 | bar_workspace_buttons
1144 | bar_color_background
1145 | bar_color_statusline
1146 | bar_color_focused_workspace
1147 | bar_color_active_workspace
1148 | bar_color_inactive_workspace
1149 | bar_color_urgent_workspace
1153 TOK_BAR_STATUS_COMMAND STR
1155 DLOG("should add status command %s\n", $2);
1156 FREE(current_bar.status_command);
1157 current_bar.status_command = $2;
1162 TOK_BAR_I3BAR_COMMAND STR
1164 DLOG("should add i3bar_command %s\n", $2);
1165 FREE(current_bar.i3bar_command);
1166 current_bar.i3bar_command = $2;
1173 DLOG("bar output %s\n", $2);
1174 int new_outputs = current_bar.num_outputs + 1;
1175 current_bar.outputs = srealloc(current_bar.outputs, sizeof(char*) * new_outputs);
1176 current_bar.outputs[current_bar.num_outputs] = $2;
1177 current_bar.num_outputs = new_outputs;
1182 TOK_BAR_TRAY_OUTPUT STR
1184 DLOG("tray %s\n", $2);
1185 FREE(current_bar.tray_output);
1186 current_bar.tray_output = $2;
1191 TOK_BAR_POSITION bar_position_position
1193 DLOG("position %d\n", $2);
1194 current_bar.position = $2;
1198 bar_position_position:
1199 TOK_BAR_TOP { $$ = P_TOP; }
1200 | TOK_BAR_BOTTOM { $$ = P_BOTTOM; }
1204 TOK_BAR_MODE bar_mode_mode
1206 DLOG("mode %d\n", $2);
1207 current_bar.mode = $2;
1212 TOK_BAR_HIDE { $$ = M_HIDE; }
1213 | TOK_BAR_DOCK { $$ = M_DOCK; }
1217 TOK_BAR_MODIFIER bar_modifier_modifier
1219 DLOG("modifier %d\n", $2);
1220 current_bar.modifier = $2;
1223 bar_modifier_modifier:
1224 TOK_BAR_CONTROL { $$ = M_CONTROL; }
1225 | TOK_BAR_SHIFT { $$ = M_SHIFT; }
1226 | TOK_BAR_MOD1 { $$ = M_MOD1; }
1227 | TOK_BAR_MOD2 { $$ = M_MOD2; }
1228 | TOK_BAR_MOD3 { $$ = M_MOD3; }
1229 | TOK_BAR_MOD4 { $$ = M_MOD4; }
1230 | TOK_BAR_MOD5 { $$ = M_MOD5; }
1236 DLOG("font %s\n", $2);
1237 FREE(current_bar.font);
1238 current_bar.font = $2;
1242 bar_workspace_buttons:
1243 TOK_BAR_WORKSPACE_BUTTONS bool
1245 DLOG("workspace_buttons = %d\n", $2);
1246 /* We store this inverted to make the default setting right when
1247 * initializing the struct with zero. */
1248 current_bar.hide_workspace_buttons = !($2);
1253 TOK_BAR_VERBOSE bool
1255 DLOG("verbose = %d\n", $2);
1256 current_bar.verbose = $2;
1261 TOK_BAR_SOCKET_PATH STR
1263 DLOG("socket_path = %s\n", $2);
1264 FREE(current_bar.socket_path);
1265 current_bar.socket_path = $2;
1270 TOK_BAR_COLORS '{' barlines '}'
1272 /* At the moment, the TOK_BAR_COLORS token is only to make the config
1273 * friendlier for humans. We might change this in the future if it gets
1278 bar_color_background:
1279 TOK_BAR_COLOR_BACKGROUND HEXCOLOR
1281 DLOG("background = %s\n", $2);
1282 current_bar.colors.background = $2;
1286 bar_color_statusline:
1287 TOK_BAR_COLOR_STATUSLINE HEXCOLOR
1289 DLOG("statusline = %s\n", $2);
1290 current_bar.colors.statusline = $2;
1294 bar_color_focused_workspace:
1295 TOK_BAR_COLOR_FOCUSED_WORKSPACE HEXCOLOR HEXCOLOR
1297 /* Old syntax: text / background */
1298 DLOG("focused_ws = %s, %s (old)\n", $2, $3);
1299 current_bar.colors.focused_workspace_bg = $3;
1300 current_bar.colors.focused_workspace_text = $2;
1302 | TOK_BAR_COLOR_FOCUSED_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR
1304 /* New syntax: border / background / text */
1305 DLOG("focused_ws = %s, %s and %s\n", $2, $3, $4);
1306 current_bar.colors.focused_workspace_border = $2;
1307 current_bar.colors.focused_workspace_bg = $3;
1308 current_bar.colors.focused_workspace_text = $4;
1312 bar_color_active_workspace:
1313 TOK_BAR_COLOR_ACTIVE_WORKSPACE HEXCOLOR HEXCOLOR
1315 /* Old syntax: text / background */
1316 DLOG("active_ws = %s, %s (old)\n", $2, $3);
1317 current_bar.colors.active_workspace_bg = $3;
1318 current_bar.colors.active_workspace_text = $2;
1320 | TOK_BAR_COLOR_ACTIVE_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR
1322 /* New syntax: border / background / text */
1323 DLOG("active_ws = %s, %s and %s\n", $2, $3, $4);
1324 current_bar.colors.active_workspace_border = $2;
1325 current_bar.colors.active_workspace_bg = $3;
1326 current_bar.colors.active_workspace_text = $4;
1330 bar_color_inactive_workspace:
1331 TOK_BAR_COLOR_INACTIVE_WORKSPACE HEXCOLOR HEXCOLOR
1333 /* Old syntax: text / background */
1334 DLOG("inactive_ws = %s, %s (old)\n", $2, $3);
1335 current_bar.colors.inactive_workspace_bg = $3;
1336 current_bar.colors.inactive_workspace_text = $2;
1338 | TOK_BAR_COLOR_INACTIVE_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR
1340 DLOG("inactive_ws = %s, %s and %s\n", $2, $3, $4);
1341 current_bar.colors.inactive_workspace_border = $2;
1342 current_bar.colors.inactive_workspace_bg = $3;
1343 current_bar.colors.inactive_workspace_text = $4;
1347 bar_color_urgent_workspace:
1348 TOK_BAR_COLOR_URGENT_WORKSPACE HEXCOLOR HEXCOLOR
1350 /* Old syntax: text / background */
1351 DLOG("urgent_ws = %s, %s (old)\n", $2, $3);
1352 current_bar.colors.urgent_workspace_bg = $3;
1353 current_bar.colors.urgent_workspace_text = $2;
1355 | TOK_BAR_COLOR_URGENT_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR
1357 DLOG("urgent_ws = %s, %s and %s\n", $2, $3, $4);
1358 current_bar.colors.urgent_workspace_border = $2;
1359 current_bar.colors.urgent_workspace_bg = $3;
1360 current_bar.colors.urgent_workspace_text = $4;
1364 floating_maximum_size:
1365 TOKFLOATING_MAXIMUM_SIZE NUMBER WORD NUMBER
1367 printf("floating_maximum_width = %d\n", $2);
1368 printf("floating_maximum_height = %d\n", $4);
1369 config.floating_maximum_width = $2;
1370 config.floating_maximum_height = $4;
1374 floating_minimum_size:
1375 TOKFLOATING_MINIMUM_SIZE NUMBER WORD NUMBER
1377 printf("floating_minimum_width = %d\n", $2);
1378 printf("floating_minimum_height = %d\n", $4);
1379 config.floating_minimum_width = $2;
1380 config.floating_minimum_height = $4;
1385 TOKFLOATING_MODIFIER binding_modifiers
1387 DLOG("floating modifier = %d\n", $2);
1388 config.floating_modifier = $2;
1393 TOK_ORIENTATION direction
1395 DLOG("New containers should start with split direction %d\n", $2);
1396 config.default_orientation = $2;
1401 TOK_HORIZ { $$ = HORIZ; }
1402 | TOK_VERT { $$ = VERT; }
1403 | TOK_AUTO { $$ = NO_ORIENTATION; }
1407 TOK_WORKSPACE_LAYOUT layout_mode
1409 DLOG("new containers will be in mode %d\n", $2);
1410 config.default_layout = $2;
1413 /* We also need to change the layout of the already existing
1414 * workspaces here. Workspaces may exist at this point because
1415 * of the other directives which are modifying workspaces
1416 * (setting the preferred screen or name). While the workspace
1417 * objects are already created, they have never been used.
1418 * Thus, the user very likely awaits the default container mode
1419 * to trigger in this case, regardless of where it is inside
1420 * his configuration file. */
1422 TAILQ_FOREACH(ws, workspaces, workspaces) {
1423 if (ws->table == NULL)
1425 switch_layout_mode(global_conn,
1427 config.container_mode);
1431 | TOK_WORKSPACE_LAYOUT TOKSTACKLIMIT TOKSTACKLIMIT NUMBER
1433 DLOG("stack-limit %d with val %d\n", $3, $4);
1434 config.container_stack_limit = $3;
1435 config.container_stack_limit_value = $4;
1438 /* See the comment above */
1440 TAILQ_FOREACH(ws, workspaces, workspaces) {
1441 if (ws->table == NULL)
1443 Container *con = ws->table[0][0];
1444 con->stack_limit = config.container_stack_limit;
1445 con->stack_limit_value = config.container_stack_limit_value;
1452 TOK_DEFAULT { $$ = L_DEFAULT; }
1453 | TOK_STACKING { $$ = L_STACKED; }
1454 | TOK_TABBED { $$ = L_TABBED; }
1458 TOKNEWWINDOW border_style
1460 DLOG("new windows should start with border style %d\n", $2);
1461 config.default_border = $2;
1466 TOKNEWFLOAT border_style
1468 DLOG("new floating windows should start with border style %d\n", $2);
1469 config.default_floating_border = $2;
1474 TOK_NORMAL { $$ = BS_NORMAL; }
1475 | TOK_NONE { $$ = BS_NONE; }
1476 | TOK_1PIXEL { $$ = BS_1PIXEL; }
1486 DLOG("checking word \"%s\"\n", $1);
1487 $$ = (strcasecmp($1, "yes") == 0 ||
1488 strcasecmp($1, "true") == 0 ||
1489 strcasecmp($1, "on") == 0 ||
1490 strcasecmp($1, "enable") == 0 ||
1491 strcasecmp($1, "active") == 0);
1496 TOK_HIDE_EDGE_BORDERS edge_hiding_mode
1498 DLOG("hide edge borders = %d\n", $2);
1499 config.hide_edge_borders = $2;
1504 TOK_NONE { $$ = ADJ_NONE; }
1505 | TOK_VERT { $$ = ADJ_LEFT_SCREEN_EDGE | ADJ_RIGHT_SCREEN_EDGE; }
1506 | TOK_HORIZ { $$ = ADJ_UPPER_SCREEN_EDGE | ADJ_LOWER_SCREEN_EDGE; }
1507 | TOK_BOTH { $$ = ADJ_LEFT_SCREEN_EDGE | ADJ_RIGHT_SCREEN_EDGE | ADJ_UPPER_SCREEN_EDGE | ADJ_LOWER_SCREEN_EDGE; }
1508 | bool { $$ = ($1 ? ADJ_LEFT_SCREEN_EDGE | ADJ_RIGHT_SCREEN_EDGE : ADJ_NONE); }
1511 focus_follows_mouse:
1512 TOKFOCUSFOLLOWSMOUSE bool
1514 DLOG("focus follows mouse = %d\n", $2);
1515 config.disable_focus_follows_mouse = !($2);
1519 force_focus_wrapping:
1520 TOK_FORCE_FOCUS_WRAPPING bool
1522 DLOG("force focus wrapping = %d\n", $2);
1523 config.force_focus_wrapping = $2;
1528 TOK_FORCE_XINERAMA bool
1530 DLOG("force xinerama = %d\n", $2);
1531 config.force_xinerama = $2;
1536 TOK_FAKE_OUTPUTS STR
1538 DLOG("fake outputs = %s\n", $2);
1539 config.fake_outputs = $2;
1543 workspace_back_and_forth:
1544 TOK_WORKSPACE_AUTO_BAF bool
1546 DLOG("automatic workspace back-and-forth = %d\n", $2);
1547 config.workspace_auto_back_and_forth = $2;
1552 TOKWORKSPACEBAR bool
1554 DLOG("workspace bar = %d\n", $2);
1555 config.disable_workspace_bar = !($2);
1560 TOKWORKSPACE qstring_or_number TOKOUTPUT OUTPUT optional_workspace_name
1565 ELOG("The old (v3) syntax workspace <number> output <output> <name> is deprecated.\n");
1566 ELOG("Please use the new syntax: workspace \"<workspace>\" output <output>\n");
1567 ELOG("In your case, the following should work:\n");
1568 ELOG(" workspace \"%s\" output %s\n", $5, $4);
1570 context->has_warnings = true;
1573 DLOG("Assigning workspace \"%s\" to output \"%s\"\n", ws_name, $4);
1574 /* Check for earlier assignments of the same workspace so that we
1575 * don’t have assignments of a single workspace to different
1577 struct Workspace_Assignment *assignment;
1578 bool duplicate = false;
1579 TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) {
1580 if (strcasecmp(assignment->name, ws_name) == 0) {
1581 ELOG("You have a duplicate workspace assignment for workspace \"%s\"\n",
1583 assignment->output = $4;
1588 assignment = scalloc(sizeof(struct Workspace_Assignment));
1589 assignment->name = ws_name;
1590 assignment->output = $4;
1591 TAILQ_INSERT_TAIL(&ws_assignments, assignment, ws_assignments);
1594 | TOKWORKSPACE NUMBER workspace_name
1598 DLOG("Invalid workspace assignment, workspace number %d out of range\n", ws_num);
1600 DLOG("workspace name to: %s\n", $3);
1602 if ($<string>3 != NULL) {
1603 workspace_set_name(workspace_get(ws_num - 1), $<string>3);
1611 optional_workspace_name:
1612 /* empty */ { $$ = NULL; }
1613 | workspace_name { $$ = $1; }
1617 QUOTEDSTRING { $$ = $1; }
1623 TOKASSIGN window_class STR
1625 /* This is the old, deprecated form of assignments. It’s provided for
1626 * compatibility in version (4.1, 4.2, 4.3) and will be removed
1627 * afterwards. It triggers an i3-nagbar warning starting from 4.1. */
1628 ELOG("You are using the old assign syntax (without criteria). "
1629 "Please see the User's Guide for the new syntax and fix "
1630 "your config file.\n");
1631 context->has_warnings = true;
1632 printf("assignment of %s to *%s*\n", $2, $3);
1633 char *workspace = $3;
1634 char *criteria = $2;
1636 Assignment *assignment = scalloc(sizeof(Assignment));
1637 Match *match = &(assignment->match);
1640 char *separator = NULL;
1641 if ((separator = strchr(criteria, '/')) != NULL) {
1642 *(separator++) = '\0';
1644 sasprintf(&pattern, "(?i)%s", separator);
1645 match->title = regex_new(pattern);
1647 printf(" title = %s\n", separator);
1649 if (*criteria != '\0') {
1651 sasprintf(&pattern, "(?i)%s", criteria);
1652 match->class = regex_new(pattern);
1654 printf(" class = %s\n", criteria);
1658 /* Compatibility with older versions: If the assignment target starts
1659 * with ~, we create the equivalent of:
1661 * for_window [class="foo"] floating enable
1663 if (*workspace == '~') {
1665 if (*workspace == '\0') {
1666 /* This assignment was *only* for floating */
1667 assignment->type = A_COMMAND;
1668 assignment->dest.command = sstrdup("floating enable");
1669 TAILQ_INSERT_TAIL(&assignments, assignment, assignments);
1672 /* Create a new assignment and continue afterwards */
1673 Assignment *floating = scalloc(sizeof(Assignment));
1674 match_copy(&(floating->match), match);
1675 floating->type = A_COMMAND;
1676 floating->dest.command = sstrdup("floating enable");
1677 TAILQ_INSERT_TAIL(&assignments, floating, assignments);
1681 assignment->type = A_TO_WORKSPACE;
1682 assignment->dest.workspace = workspace;
1683 TAILQ_INSERT_TAIL(&assignments, assignment, assignments);
1685 | TOKASSIGN match STR
1687 if (match_is_empty(¤t_match)) {
1688 ELOG("Match is empty, ignoring this assignment\n");
1691 printf("new assignment, using above criteria, to workspace %s\n", $3);
1692 Assignment *assignment = scalloc(sizeof(Assignment));
1693 assignment->match = current_match;
1694 assignment->type = A_TO_WORKSPACE;
1695 assignment->dest.workspace = $3;
1696 TAILQ_INSERT_TAIL(&assignments, assignment, assignments);
1708 config.ipc_socket_path = $2;
1715 config.restart_state_path = $2;
1720 TOKEXEC optional_no_startup_id STR
1722 struct Autostart *new = smalloc(sizeof(struct Autostart));
1724 new->no_startup_id = $2;
1725 TAILQ_INSERT_TAIL(&autostarts, new, autostarts);
1730 TOKEXEC_ALWAYS optional_no_startup_id STR
1732 struct Autostart *new = smalloc(sizeof(struct Autostart));
1734 new->no_startup_id = $2;
1735 TAILQ_INSERT_TAIL(&autostarts_always, new, autostarts_always);
1739 optional_no_startup_id:
1740 /* empty */ { $$ = false; }
1741 | TOK_NO_STARTUP_ID { $$ = true; }
1747 ELOG("The terminal option is DEPRECATED and has no effect. "
1748 "Please remove it from your configuration file.\n");
1755 config.font = load_font($2, true);
1756 set_font(&config.font);
1757 printf("font %s\n", $2);
1764 TOKSINGLECOLOR colorpixel
1766 uint32_t *dest = $1;
1772 TOKCOLOR colorpixel colorpixel colorpixel
1774 struct Colortriple *dest = $1;
1777 dest->background = $3;
1780 | TOKCOLOR colorpixel colorpixel colorpixel colorpixel
1782 struct Colortriple *dest = $1;
1785 dest->background = $3;
1787 dest->indicator = $5;
1794 $$ = get_colorpixel($1);
1801 /* NULL */ { $$ = 0; }
1803 | binding_modifiers '+' binding_modifier { $$ = $1 | $3; }
1804 | binding_modifiers '+' { $$ = $1; }
1808 MODIFIER { $$ = $1; }
1809 | TOKCONTROL { $$ = BIND_CONTROL; }
1810 | TOKSHIFT { $$ = BIND_SHIFT; }
1813 popup_during_fullscreen:
1814 TOK_POPUP_DURING_FULLSCREEN popup_setting
1816 DLOG("popup_during_fullscreen setting: %d\n", $2);
1817 config.popup_during_fullscreen = $2;
1822 TOK_IGNORE { $$ = PDF_IGNORE; }
1823 | TOK_LEAVE_FULLSCREEN { $$ = PDF_LEAVE_FULLSCREEN; }