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)
436 context->has_errors = true;
437 if (current->keycode != 0) {
438 ELOG("Duplicate keybinding in config file:\n modmask %d with keycode %d, command \"%s\"\n",
439 current->mods, current->keycode, current->command);
441 ELOG("Duplicate keybinding in config file:\n modmask %d with keysym %s, command \"%s\"\n",
442 current->mods, current->symbol, current->command);
448 static void migrate_i3bar_exec(struct Autostart *exec) {
449 ELOG("**********************************************************************\n");
450 ELOG("IGNORING exec command: %s\n", exec->command);
451 ELOG("It contains \"i3bar\". Since i3 v4.1, i3bar will be automatically started\n");
452 ELOG("for each 'bar' configuration block in your i3 config. Please remove the exec\n");
453 ELOG("line and add the following to your i3 config:\n");
456 ELOG(" status_command i3status\n");
458 ELOG("**********************************************************************\n");
460 /* Generate a dummy bar configuration */
461 Barconfig *bar_config = scalloc(sizeof(Barconfig));
462 /* The hard-coded ID is not a problem. It does not conflict with the
463 * auto-generated bar IDs and having multiple hard-coded IDs is irrelevant
464 * – they all just contain status_command = i3status */
465 bar_config->id = sstrdup("migrate-bar");
466 bar_config->status_command = sstrdup("i3status");
467 TAILQ_INSERT_TAIL(&barconfigs, bar_config, configs);
469 /* Trigger an i3-nagbar */
470 context->has_warnings = true;
473 void parse_file(const char *f) {
474 SLIST_HEAD(variables_head, Variable) variables = SLIST_HEAD_INITIALIZER(&variables);
475 int fd, ret, read_bytes = 0;
479 char buffer[1026], key[512], value[512];
481 if ((fd = open(f, O_RDONLY)) == -1)
482 die("Could not open configuration file: %s\n", strerror(errno));
484 if (fstat(fd, &stbuf) == -1)
485 die("Could not fstat file: %s\n", strerror(errno));
487 buf = scalloc((stbuf.st_size + 1) * sizeof(char));
488 while (read_bytes < stbuf.st_size) {
489 if ((ret = read(fd, buf + read_bytes, (stbuf.st_size - read_bytes))) < 0)
490 die("Could not read(): %s\n", strerror(errno));
494 if (lseek(fd, 0, SEEK_SET) == (off_t)-1)
495 die("Could not lseek: %s\n", strerror(errno));
497 if ((fstr = fdopen(fd, "r")) == NULL)
498 die("Could not fdopen: %s\n", strerror(errno));
500 while (!feof(fstr)) {
501 if (fgets(buffer, 1024, fstr) == NULL) {
504 die("Could not read configuration file\n");
507 /* sscanf implicitly strips whitespace. Also, we skip comments and empty lines. */
508 if (sscanf(buffer, "%s %[^\n]", key, value) < 1 ||
509 key[0] == '#' || strlen(key) < 3)
512 if (strcasecmp(key, "set") == 0) {
513 if (value[0] != '$') {
514 ELOG("Malformed variable assignment, name has to start with $\n");
518 /* get key/value for this variable */
519 char *v_key = value, *v_value;
520 if (strstr(value, " ") == NULL && strstr(value, "\t") == NULL) {
521 ELOG("Malformed variable assignment, need a value\n");
525 if (!(v_value = strstr(value, " ")))
526 v_value = strstr(value, "\t");
529 while (*v_value == '\t' || *v_value == ' ')
532 struct Variable *new = scalloc(sizeof(struct Variable));
533 new->key = sstrdup(v_key);
534 new->value = sstrdup(v_value);
535 SLIST_INSERT_HEAD(&variables, new, variables);
536 DLOG("Got new variable %s = %s\n", v_key, v_value);
542 /* For every custom variable, see how often it occurs in the file and
543 * how much extra bytes it requires when replaced. */
544 struct Variable *current, *nearest;
546 /* We need to copy the buffer because we need to invalidate the
547 * variables (otherwise we will count them twice, which is bad when
548 * 'extra' is negative) */
549 char *bufcopy = sstrdup(buf);
550 SLIST_FOREACH(current, &variables, variables) {
551 int extra = (strlen(current->value) - strlen(current->key));
554 next < (bufcopy + stbuf.st_size) &&
555 (next = strcasestr(next, current->key)) != NULL;
556 next += strlen(current->key)) {
558 extra_bytes += extra;
563 /* Then, allocate a new buffer and copy the file over to the new one,
564 * but replace occurences of our variables */
565 char *walk = buf, *destwalk;
566 char *new = smalloc((stbuf.st_size + extra_bytes + 1) * sizeof(char));
568 while (walk < (buf + stbuf.st_size)) {
569 /* Find the next variable */
570 SLIST_FOREACH(current, &variables, variables)
571 current->next_match = strcasestr(walk, current->key);
573 int distance = stbuf.st_size;
574 SLIST_FOREACH(current, &variables, variables) {
575 if (current->next_match == NULL)
577 if ((current->next_match - walk) < distance) {
578 distance = (current->next_match - walk);
582 if (nearest == NULL) {
583 /* If there are no more variables, we just copy the rest */
584 strncpy(destwalk, walk, (buf + stbuf.st_size) - walk);
585 destwalk += (buf + stbuf.st_size) - walk;
589 /* Copy until the next variable, then copy its value */
590 strncpy(destwalk, walk, distance);
591 strncpy(destwalk + distance, nearest->value, strlen(nearest->value));
592 walk += distance + strlen(nearest->key);
593 destwalk += distance + strlen(nearest->value);
597 /* analyze the string to find out whether this is an old config file (3.x)
598 * or a new config file (4.x). If it’s old, we run the converter script. */
599 int version = detect_version(buf);
601 /* We need to convert this v3 configuration */
602 char *converted = migrate_config(new, stbuf.st_size);
603 if (converted != NULL) {
605 ELOG("****************************************************************\n");
606 ELOG("NOTE: Automatically converted configuration file from v3 to v4.\n");
608 ELOG("Please convert your config file to v4. You can use this command:\n");
609 ELOG(" mv %s %s.O\n", f, f);
610 ELOG(" i3-migrate-config-to-v4 %s.O > %s\n", f, f);
611 ELOG("****************************************************************\n");
617 printf("**********************************************************************\n");
618 printf("ERROR: Could not convert config file. Maybe i3-migrate-config-to-v4\n");
619 printf("was not correctly installed on your system?\n");
620 printf("**********************************************************************\n");
625 /* now lex/parse it */
628 context = scalloc(sizeof(struct context));
629 context->filename = f;
631 if (yyparse() != 0) {
632 fprintf(stderr, "Could not parse configfile\n");
636 check_for_duplicate_bindings(context);
638 /* XXX: The following code will be removed in i3 v4.3 (three releases from
639 * now, as of 2011-10-22) */
640 /* Check for any exec or exec_always lines starting i3bar. We remove these
641 * and add a bar block instead. Additionally, a i3-nagbar warning (not an
642 * error) will be displayed so that users update their config file. */
643 struct Autostart *exec, *next;
644 for (exec = TAILQ_FIRST(&autostarts); exec; ) {
645 next = TAILQ_NEXT(exec, autostarts);
646 if (strstr(exec->command, "i3bar") != NULL) {
647 migrate_i3bar_exec(exec);
648 TAILQ_REMOVE(&autostarts, exec, autostarts);
653 for (exec = TAILQ_FIRST(&autostarts_always); exec; ) {
654 next = TAILQ_NEXT(exec, autostarts_always);
655 if (strstr(exec->command, "i3bar") != NULL) {
656 migrate_i3bar_exec(exec);
657 TAILQ_REMOVE(&autostarts_always, exec, autostarts_always);
662 if (context->has_errors || context->has_warnings) {
663 ELOG("FYI: You are using i3 version " I3_VERSION "\n");
665 ELOG("Please convert your configfile first, then fix any remaining errors (see above).\n");
666 start_configerror_nagbar(f);
670 FREE(context->line_copy);
676 while (!SLIST_EMPTY(&variables)) {
677 current = SLIST_FIRST(&variables);
679 FREE(current->value);
680 SLIST_REMOVE_HEAD(&variables, variables);
688 %lex-param { struct context *context }
693 uint32_t *single_color;
694 struct Colortriple *color;
696 struct Binding *binding;
699 %token <number> NUMBER "<number>"
700 %token <string> WORD "<word>"
701 %token <string> STR "<string>"
702 %token <string> STR_NG "<string (non-greedy)>"
703 %token <string> HEXCOLOR "#<hex>"
704 %token <string> OUTPUT "<RandR output>"
707 %token TOKCOMMENT "<comment>"
708 %token TOKFONT "font"
709 %token TOKBINDSYM "bindsym"
710 %token <number> MODIFIER "<modifier>"
711 %token TOKCONTROL "control"
712 %token TOKSHIFT "shift"
713 %token TOKFLOATING_MODIFIER "floating_modifier"
714 %token TOKFLOATING_MAXIMUM_SIZE "floating_maximum_size"
715 %token TOKFLOATING_MINIMUM_SIZE "floating_minimum_size"
716 %token <string> QUOTEDSTRING "<quoted string>"
717 %token TOKWORKSPACE "workspace"
718 %token TOKOUTPUT "output"
719 %token TOKASSIGN "assign"
721 %token TOKIPCSOCKET "ipc_socket"
722 %token TOKRESTARTSTATE "restart_state"
723 %token TOKEXEC "exec"
724 %token TOKEXEC_ALWAYS "exec_always"
725 %token <single_color> TOKSINGLECOLOR
726 %token <color> TOKCOLOR
728 %token TOKMODE "mode"
730 %token TOK_ORIENTATION "default_orientation"
731 %token TOK_HORIZ "horizontal"
732 %token TOK_VERT "vertical"
733 %token TOK_AUTO "auto"
734 %token TOK_WORKSPACE_LAYOUT "workspace_layout"
735 %token TOKNEWWINDOW "new_window"
736 %token TOKNEWFLOAT "new_float"
737 %token TOK_NORMAL "normal"
738 %token TOK_NONE "none"
739 %token TOK_1PIXEL "1pixel"
740 %token TOK_HIDE_EDGE_BORDERS "hide_edge_borders"
741 %token TOK_BOTH "both"
742 %token TOKFOCUSFOLLOWSMOUSE "focus_follows_mouse"
743 %token TOK_FORCE_FOCUS_WRAPPING "force_focus_wrapping"
744 %token TOK_FORCE_XINERAMA "force_xinerama"
745 %token TOK_FAKE_OUTPUTS "fake_outputs"
746 %token TOK_WORKSPACE_AUTO_BAF "workspace_auto_back_and_forth"
747 %token TOKWORKSPACEBAR "workspace_bar"
748 %token TOK_DEFAULT "default"
749 %token TOK_STACKING "stacking"
750 %token TOK_TABBED "tabbed"
751 %token <number> TOKSTACKLIMIT "stack-limit"
752 %token TOK_POPUP_DURING_FULLSCREEN "popup_during_fullscreen"
753 %token TOK_IGNORE "ignore"
754 %token TOK_LEAVE_FULLSCREEN "leave_fullscreen"
755 %token TOK_FOR_WINDOW "for_window"
757 %token TOK_BAR_OUTPUT "output (bar)"
758 %token TOK_BAR_TRAY_OUTPUT "tray_output"
759 %token TOK_BAR_SOCKET_PATH "socket_path"
760 %token TOK_BAR_MODE "mode (bar)"
761 %token TOK_BAR_HIDE "hide"
762 %token TOK_BAR_DOCK "dock"
763 %token TOK_BAR_MODIFIER "modifier (bar)"
764 %token TOK_BAR_CONTROL "shift (bar)"
765 %token TOK_BAR_SHIFT "control (bar)"
766 %token TOK_BAR_MOD1 "Mod1"
767 %token TOK_BAR_MOD2 "Mod2"
768 %token TOK_BAR_MOD3 "Mod3"
769 %token TOK_BAR_MOD4 "Mod4"
770 %token TOK_BAR_MOD5 "Mod5"
771 %token TOK_BAR_POSITION "position"
772 %token TOK_BAR_BOTTOM "bottom"
773 %token TOK_BAR_TOP "top"
774 %token TOK_BAR_STATUS_COMMAND "status_command"
775 %token TOK_BAR_I3BAR_COMMAND "i3bar_command"
776 %token TOK_BAR_FONT "font (bar)"
777 %token TOK_BAR_WORKSPACE_BUTTONS "workspace_buttons"
778 %token TOK_BAR_VERBOSE "verbose"
779 %token TOK_BAR_COLORS "colors"
780 %token TOK_BAR_COLOR_BACKGROUND "background"
781 %token TOK_BAR_COLOR_STATUSLINE "statusline"
782 %token TOK_BAR_COLOR_FOCUSED_WORKSPACE "focused_workspace"
783 %token TOK_BAR_COLOR_ACTIVE_WORKSPACE "active_workspace"
784 %token TOK_BAR_COLOR_INACTIVE_WORKSPACE "inactive_workspace"
785 %token TOK_BAR_COLOR_URGENT_WORKSPACE "urgent_workspace"
786 %token TOK_NO_STARTUP_ID "--no-startup-id"
787 %token TOK_RELEASE "--release"
789 %token TOK_MARK "mark"
790 %token TOK_CLASS "class"
791 %token TOK_INSTANCE "instance"
792 %token TOK_WINDOW_ROLE "window_role"
794 %token TOK_CON_ID "con_id"
795 %token TOK_TITLE "title"
796 %token TOK_URGENT "urgent"
798 %type <binding> binding
799 %type <binding> bindcode
800 %type <binding> bindsym
801 %type <number> binding_modifiers
802 %type <number> binding_modifier
803 %type <number> direction
804 %type <number> layout_mode
805 %type <number> border_style
806 %type <number> new_window
807 %type <number> hide_edge_borders
808 %type <number> edge_hiding_mode
809 %type <number> new_float
810 %type <number> colorpixel
812 %type <number> popup_setting
813 %type <number> bar_position_position
814 %type <number> bar_mode_mode
815 %type <number> bar_modifier_modifier
816 %type <number> optional_no_startup_id
817 %type <number> optional_release
818 %type <string> command
819 %type <string> word_or_number
820 %type <string> qstring_or_number
821 %type <string> optional_workspace_name
822 %type <string> workspace_name
823 %type <string> window_class
837 | floating_maximum_size
838 | floating_minimum_size
845 | focus_follows_mouse
846 | force_focus_wrapping
849 | workspace_back_and_forth
862 | popup_during_fullscreen
876 TAILQ_INSERT_TAIL(bindings, $1, bindings);
881 TOKBINDCODE bindcode { $$ = $2; }
882 | TOKBINDSYM bindsym { $$ = $2; }
886 optional_release binding_modifiers NUMBER command
888 DLOG("bindcode: release = %d, mod = %d, key = %d, command = %s\n", $1, $2, $3, $4);
889 Binding *new = scalloc(sizeof(Binding));
901 optional_release binding_modifiers word_or_number command
903 DLOG("bindsym: release = %d, mod = %d, key = %s, command = %s\n", $1, $2, $3, $4);
904 Binding *new = scalloc(sizeof(Binding));
916 /* empty */ { $$ = B_UPON_KEYPRESS; }
917 | TOK_RELEASE { $$ = B_UPON_KEYRELEASE; }
921 TOK_FOR_WINDOW match command
923 if (match_is_empty(¤t_match)) {
924 ELOG("Match is empty, ignoring this for_window statement\n");
927 printf("\t should execute command %s for the criteria mentioned above\n", $3);
928 Assignment *assignment = scalloc(sizeof(Assignment));
929 assignment->type = A_COMMAND;
930 assignment->match = current_match;
931 assignment->dest.command = $3;
932 TAILQ_INSERT_TAIL(&assignments, assignment, assignments);
937 | matchstart criteria matchend
939 printf("match parsed\n");
947 match_init(¤t_match);
954 printf("match specification finished\n");
966 printf("criteria: class = %s\n", $3);
967 current_match.class = regex_new($3);
970 | TOK_INSTANCE '=' STR
972 printf("criteria: instance = %s\n", $3);
973 current_match.instance = regex_new($3);
976 | TOK_WINDOW_ROLE '=' STR
978 printf("criteria: window_role = %s\n", $3);
979 current_match.role = regex_new($3);
984 printf("criteria: id = %s\n", $3);
986 long parsed = strtol($3, &end, 10);
987 if (parsed == LONG_MIN ||
988 parsed == LONG_MAX ||
990 (end && *end != '\0')) {
991 ELOG("Could not parse con id \"%s\"\n", $3);
993 current_match.con_id = (Con*)parsed;
994 printf("id as int = %p\n", current_match.con_id);
999 printf("criteria: window id = %s\n", $3);
1001 long parsed = strtol($3, &end, 10);
1002 if (parsed == LONG_MIN ||
1003 parsed == LONG_MAX ||
1005 (end && *end != '\0')) {
1006 ELOG("Could not parse window id \"%s\"\n", $3);
1008 current_match.id = parsed;
1009 printf("window id as int = %d\n", current_match.id);
1014 printf("criteria: mark = %s\n", $3);
1015 current_match.mark = regex_new($3);
1020 printf("criteria: title = %s\n", $3);
1021 current_match.title = regex_new($3);
1024 | TOK_URGENT '=' STR
1026 printf("criteria: urgent = %s\n", $3);
1027 if (strcasecmp($3, "latest") == 0 ||
1028 strcasecmp($3, "newest") == 0 ||
1029 strcasecmp($3, "recent") == 0 ||
1030 strcasecmp($3, "last") == 0) {
1031 current_match.urgent = U_LATEST;
1032 } else if (strcasecmp($3, "oldest") == 0 ||
1033 strcasecmp($3, "first") == 0) {
1034 current_match.urgent = U_OLDEST;
1042 | NUMBER { sasprintf(&$$, "%d", $1); }
1049 sasprintf(&$$, "%d", $1);
1054 TOKMODE QUOTEDSTRING '{' modelines '}'
1056 if (strcasecmp($2, "default") == 0) {
1057 printf("You cannot use the name \"default\" for your mode\n");
1060 printf("\t now in mode %s\n", $2);
1061 printf("\t current bindings = %p\n", current_bindings);
1063 TAILQ_FOREACH(binding, current_bindings, bindings) {
1064 printf("got binding on mods %d, keycode %d, symbol %s, command %s\n",
1065 binding->mods, binding->keycode, binding->symbol, binding->command);
1068 struct Mode *mode = scalloc(sizeof(struct Mode));
1070 mode->bindings = current_bindings;
1071 current_bindings = NULL;
1072 SLIST_INSERT_HEAD(&modes, mode, modes);
1079 | modelines modeline
1086 if (current_bindings == NULL) {
1087 current_bindings = scalloc(sizeof(struct bindings_head));
1088 TAILQ_INIT(current_bindings);
1091 TAILQ_INSERT_TAIL(current_bindings, $1, bindings);
1096 TOK_BAR '{' barlines '}'
1098 printf("\t new bar configuration finished, saving.\n");
1099 /* Generate a unique ID for this bar */
1100 current_bar.id = sstrdup("bar-XXXXXX");
1101 /* This works similar to mktemp in that it replaces the last six X with
1102 * random letters, but without the restriction that the given buffer
1103 * has to contain a valid path name. */
1104 char *x = current_bar.id + strlen("bar-");
1105 while (*x != '\0') {
1106 *(x++) = (rand() % 26) + 'a';
1109 /* If no font was explicitly set, we use the i3 font as default */
1110 if (!current_bar.font && font_pattern)
1111 current_bar.font = sstrdup(font_pattern);
1113 /* Copy the current (static) structure into a dynamically allocated
1114 * one, then cleanup our static one. */
1115 Barconfig *bar_config = scalloc(sizeof(Barconfig));
1116 memcpy(bar_config, ¤t_bar, sizeof(Barconfig));
1117 TAILQ_INSERT_TAIL(&barconfigs, bar_config, configs);
1119 memset(¤t_bar, '\0', sizeof(Barconfig));
1130 | bar_status_command
1138 | bar_workspace_buttons
1142 | bar_color_background
1143 | bar_color_statusline
1144 | bar_color_focused_workspace
1145 | bar_color_active_workspace
1146 | bar_color_inactive_workspace
1147 | bar_color_urgent_workspace
1151 TOK_BAR_STATUS_COMMAND STR
1153 DLOG("should add status command %s\n", $2);
1154 FREE(current_bar.status_command);
1155 current_bar.status_command = $2;
1160 TOK_BAR_I3BAR_COMMAND STR
1162 DLOG("should add i3bar_command %s\n", $2);
1163 FREE(current_bar.i3bar_command);
1164 current_bar.i3bar_command = $2;
1171 DLOG("bar output %s\n", $2);
1172 int new_outputs = current_bar.num_outputs + 1;
1173 current_bar.outputs = srealloc(current_bar.outputs, sizeof(char*) * new_outputs);
1174 current_bar.outputs[current_bar.num_outputs] = $2;
1175 current_bar.num_outputs = new_outputs;
1180 TOK_BAR_TRAY_OUTPUT STR
1182 DLOG("tray %s\n", $2);
1183 FREE(current_bar.tray_output);
1184 current_bar.tray_output = $2;
1189 TOK_BAR_POSITION bar_position_position
1191 DLOG("position %d\n", $2);
1192 current_bar.position = $2;
1196 bar_position_position:
1197 TOK_BAR_TOP { $$ = P_TOP; }
1198 | TOK_BAR_BOTTOM { $$ = P_BOTTOM; }
1202 TOK_BAR_MODE bar_mode_mode
1204 DLOG("mode %d\n", $2);
1205 current_bar.mode = $2;
1210 TOK_BAR_HIDE { $$ = M_HIDE; }
1211 | TOK_BAR_DOCK { $$ = M_DOCK; }
1215 TOK_BAR_MODIFIER bar_modifier_modifier
1217 DLOG("modifier %d\n", $2);
1218 current_bar.modifier = $2;
1221 bar_modifier_modifier:
1222 TOK_BAR_CONTROL { $$ = M_CONTROL; }
1223 | TOK_BAR_SHIFT { $$ = M_SHIFT; }
1224 | TOK_BAR_MOD1 { $$ = M_MOD1; }
1225 | TOK_BAR_MOD2 { $$ = M_MOD2; }
1226 | TOK_BAR_MOD3 { $$ = M_MOD3; }
1227 | TOK_BAR_MOD4 { $$ = M_MOD4; }
1228 | TOK_BAR_MOD5 { $$ = M_MOD5; }
1234 DLOG("font %s\n", $2);
1235 FREE(current_bar.font);
1236 current_bar.font = $2;
1240 bar_workspace_buttons:
1241 TOK_BAR_WORKSPACE_BUTTONS bool
1243 DLOG("workspace_buttons = %d\n", $2);
1244 /* We store this inverted to make the default setting right when
1245 * initializing the struct with zero. */
1246 current_bar.hide_workspace_buttons = !($2);
1251 TOK_BAR_VERBOSE bool
1253 DLOG("verbose = %d\n", $2);
1254 current_bar.verbose = $2;
1259 TOK_BAR_SOCKET_PATH STR
1261 DLOG("socket_path = %s\n", $2);
1262 FREE(current_bar.socket_path);
1263 current_bar.socket_path = $2;
1268 TOK_BAR_COLORS '{' barlines '}'
1270 /* At the moment, the TOK_BAR_COLORS token is only to make the config
1271 * friendlier for humans. We might change this in the future if it gets
1276 bar_color_background:
1277 TOK_BAR_COLOR_BACKGROUND HEXCOLOR
1279 DLOG("background = %s\n", $2);
1280 current_bar.colors.background = $2;
1284 bar_color_statusline:
1285 TOK_BAR_COLOR_STATUSLINE HEXCOLOR
1287 DLOG("statusline = %s\n", $2);
1288 current_bar.colors.statusline = $2;
1292 bar_color_focused_workspace:
1293 TOK_BAR_COLOR_FOCUSED_WORKSPACE HEXCOLOR HEXCOLOR
1295 /* Old syntax: text / background */
1296 DLOG("focused_ws = %s, %s (old)\n", $2, $3);
1297 current_bar.colors.focused_workspace_bg = $3;
1298 current_bar.colors.focused_workspace_text = $2;
1300 | TOK_BAR_COLOR_FOCUSED_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR
1302 /* New syntax: border / background / text */
1303 DLOG("focused_ws = %s, %s and %s\n", $2, $3, $4);
1304 current_bar.colors.focused_workspace_border = $2;
1305 current_bar.colors.focused_workspace_bg = $3;
1306 current_bar.colors.focused_workspace_text = $4;
1310 bar_color_active_workspace:
1311 TOK_BAR_COLOR_ACTIVE_WORKSPACE HEXCOLOR HEXCOLOR
1313 /* Old syntax: text / background */
1314 DLOG("active_ws = %s, %s (old)\n", $2, $3);
1315 current_bar.colors.active_workspace_bg = $3;
1316 current_bar.colors.active_workspace_text = $2;
1318 | TOK_BAR_COLOR_ACTIVE_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR
1320 /* New syntax: border / background / text */
1321 DLOG("active_ws = %s, %s and %s\n", $2, $3, $4);
1322 current_bar.colors.active_workspace_border = $2;
1323 current_bar.colors.active_workspace_bg = $3;
1324 current_bar.colors.active_workspace_text = $4;
1328 bar_color_inactive_workspace:
1329 TOK_BAR_COLOR_INACTIVE_WORKSPACE HEXCOLOR HEXCOLOR
1331 /* Old syntax: text / background */
1332 DLOG("inactive_ws = %s, %s (old)\n", $2, $3);
1333 current_bar.colors.inactive_workspace_bg = $3;
1334 current_bar.colors.inactive_workspace_text = $2;
1336 | TOK_BAR_COLOR_INACTIVE_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR
1338 DLOG("inactive_ws = %s, %s and %s\n", $2, $3, $4);
1339 current_bar.colors.inactive_workspace_border = $2;
1340 current_bar.colors.inactive_workspace_bg = $3;
1341 current_bar.colors.inactive_workspace_text = $4;
1345 bar_color_urgent_workspace:
1346 TOK_BAR_COLOR_URGENT_WORKSPACE HEXCOLOR HEXCOLOR
1348 /* Old syntax: text / background */
1349 DLOG("urgent_ws = %s, %s (old)\n", $2, $3);
1350 current_bar.colors.urgent_workspace_bg = $3;
1351 current_bar.colors.urgent_workspace_text = $2;
1353 | TOK_BAR_COLOR_URGENT_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR
1355 DLOG("urgent_ws = %s, %s and %s\n", $2, $3, $4);
1356 current_bar.colors.urgent_workspace_border = $2;
1357 current_bar.colors.urgent_workspace_bg = $3;
1358 current_bar.colors.urgent_workspace_text = $4;
1362 floating_maximum_size:
1363 TOKFLOATING_MAXIMUM_SIZE NUMBER WORD NUMBER
1365 printf("floating_maximum_width = %d\n", $2);
1366 printf("floating_maximum_height = %d\n", $4);
1367 config.floating_maximum_width = $2;
1368 config.floating_maximum_height = $4;
1372 floating_minimum_size:
1373 TOKFLOATING_MINIMUM_SIZE NUMBER WORD NUMBER
1375 printf("floating_minimum_width = %d\n", $2);
1376 printf("floating_minimum_height = %d\n", $4);
1377 config.floating_minimum_width = $2;
1378 config.floating_minimum_height = $4;
1383 TOKFLOATING_MODIFIER binding_modifiers
1385 DLOG("floating modifier = %d\n", $2);
1386 config.floating_modifier = $2;
1391 TOK_ORIENTATION direction
1393 DLOG("New containers should start with split direction %d\n", $2);
1394 config.default_orientation = $2;
1399 TOK_HORIZ { $$ = HORIZ; }
1400 | TOK_VERT { $$ = VERT; }
1401 | TOK_AUTO { $$ = NO_ORIENTATION; }
1405 TOK_WORKSPACE_LAYOUT layout_mode
1407 DLOG("new containers will be in mode %d\n", $2);
1408 config.default_layout = $2;
1411 /* We also need to change the layout of the already existing
1412 * workspaces here. Workspaces may exist at this point because
1413 * of the other directives which are modifying workspaces
1414 * (setting the preferred screen or name). While the workspace
1415 * objects are already created, they have never been used.
1416 * Thus, the user very likely awaits the default container mode
1417 * to trigger in this case, regardless of where it is inside
1418 * his configuration file. */
1420 TAILQ_FOREACH(ws, workspaces, workspaces) {
1421 if (ws->table == NULL)
1423 switch_layout_mode(global_conn,
1425 config.container_mode);
1429 | TOK_WORKSPACE_LAYOUT TOKSTACKLIMIT TOKSTACKLIMIT NUMBER
1431 DLOG("stack-limit %d with val %d\n", $3, $4);
1432 config.container_stack_limit = $3;
1433 config.container_stack_limit_value = $4;
1436 /* See the comment above */
1438 TAILQ_FOREACH(ws, workspaces, workspaces) {
1439 if (ws->table == NULL)
1441 Container *con = ws->table[0][0];
1442 con->stack_limit = config.container_stack_limit;
1443 con->stack_limit_value = config.container_stack_limit_value;
1450 TOK_DEFAULT { $$ = L_DEFAULT; }
1451 | TOK_STACKING { $$ = L_STACKED; }
1452 | TOK_TABBED { $$ = L_TABBED; }
1456 TOKNEWWINDOW border_style
1458 DLOG("new windows should start with border style %d\n", $2);
1459 config.default_border = $2;
1464 TOKNEWFLOAT border_style
1466 DLOG("new floating windows should start with border style %d\n", $2);
1467 config.default_floating_border = $2;
1472 TOK_NORMAL { $$ = BS_NORMAL; }
1473 | TOK_NONE { $$ = BS_NONE; }
1474 | TOK_1PIXEL { $$ = BS_1PIXEL; }
1484 DLOG("checking word \"%s\"\n", $1);
1485 $$ = (strcasecmp($1, "yes") == 0 ||
1486 strcasecmp($1, "true") == 0 ||
1487 strcasecmp($1, "on") == 0 ||
1488 strcasecmp($1, "enable") == 0 ||
1489 strcasecmp($1, "active") == 0);
1494 TOK_HIDE_EDGE_BORDERS edge_hiding_mode
1496 DLOG("hide edge borders = %d\n", $2);
1497 config.hide_edge_borders = $2;
1502 TOK_NONE { $$ = ADJ_NONE; }
1503 | TOK_VERT { $$ = ADJ_LEFT_SCREEN_EDGE | ADJ_RIGHT_SCREEN_EDGE; }
1504 | TOK_HORIZ { $$ = ADJ_UPPER_SCREEN_EDGE | ADJ_LOWER_SCREEN_EDGE; }
1505 | TOK_BOTH { $$ = ADJ_LEFT_SCREEN_EDGE | ADJ_RIGHT_SCREEN_EDGE | ADJ_UPPER_SCREEN_EDGE | ADJ_LOWER_SCREEN_EDGE; }
1506 | bool { $$ = ($1 ? ADJ_LEFT_SCREEN_EDGE | ADJ_RIGHT_SCREEN_EDGE : ADJ_NONE); }
1509 focus_follows_mouse:
1510 TOKFOCUSFOLLOWSMOUSE bool
1512 DLOG("focus follows mouse = %d\n", $2);
1513 config.disable_focus_follows_mouse = !($2);
1517 force_focus_wrapping:
1518 TOK_FORCE_FOCUS_WRAPPING bool
1520 DLOG("force focus wrapping = %d\n", $2);
1521 config.force_focus_wrapping = $2;
1526 TOK_FORCE_XINERAMA bool
1528 DLOG("force xinerama = %d\n", $2);
1529 config.force_xinerama = $2;
1534 TOK_FAKE_OUTPUTS STR
1536 DLOG("fake outputs = %s\n", $2);
1537 config.fake_outputs = $2;
1541 workspace_back_and_forth:
1542 TOK_WORKSPACE_AUTO_BAF bool
1544 DLOG("automatic workspace back-and-forth = %d\n", $2);
1545 config.workspace_auto_back_and_forth = $2;
1550 TOKWORKSPACEBAR bool
1552 DLOG("workspace bar = %d\n", $2);
1553 config.disable_workspace_bar = !($2);
1558 TOKWORKSPACE qstring_or_number TOKOUTPUT OUTPUT optional_workspace_name
1563 ELOG("The old (v3) syntax workspace <number> output <output> <name> is deprecated.\n");
1564 ELOG("Please use the new syntax: workspace \"<workspace>\" output <output>\n");
1565 ELOG("In your case, the following should work:\n");
1566 ELOG(" workspace \"%s\" output %s\n", $5, $4);
1568 context->has_warnings = true;
1571 DLOG("Assigning workspace \"%s\" to output \"%s\"\n", ws_name, $4);
1572 /* Check for earlier assignments of the same workspace so that we
1573 * don’t have assignments of a single workspace to different
1575 struct Workspace_Assignment *assignment;
1576 bool duplicate = false;
1577 TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) {
1578 if (strcasecmp(assignment->name, ws_name) == 0) {
1579 ELOG("You have a duplicate workspace assignment for workspace \"%s\"\n",
1581 assignment->output = $4;
1586 assignment = scalloc(sizeof(struct Workspace_Assignment));
1587 assignment->name = ws_name;
1588 assignment->output = $4;
1589 TAILQ_INSERT_TAIL(&ws_assignments, assignment, ws_assignments);
1592 | TOKWORKSPACE NUMBER workspace_name
1596 DLOG("Invalid workspace assignment, workspace number %d out of range\n", ws_num);
1598 DLOG("workspace name to: %s\n", $3);
1600 if ($<string>3 != NULL) {
1601 workspace_set_name(workspace_get(ws_num - 1), $<string>3);
1609 optional_workspace_name:
1610 /* empty */ { $$ = NULL; }
1611 | workspace_name { $$ = $1; }
1615 QUOTEDSTRING { $$ = $1; }
1621 TOKASSIGN window_class STR
1623 /* This is the old, deprecated form of assignments. It’s provided for
1624 * compatibility in version (4.1, 4.2, 4.3) and will be removed
1625 * afterwards. It triggers an i3-nagbar warning starting from 4.1. */
1626 ELOG("You are using the old assign syntax (without criteria). "
1627 "Please see the User's Guide for the new syntax and fix "
1628 "your config file.\n");
1629 context->has_warnings = true;
1630 printf("assignment of %s to *%s*\n", $2, $3);
1631 char *workspace = $3;
1632 char *criteria = $2;
1634 Assignment *assignment = scalloc(sizeof(Assignment));
1635 Match *match = &(assignment->match);
1638 char *separator = NULL;
1639 if ((separator = strchr(criteria, '/')) != NULL) {
1640 *(separator++) = '\0';
1642 sasprintf(&pattern, "(?i)%s", separator);
1643 match->title = regex_new(pattern);
1645 printf(" title = %s\n", separator);
1647 if (*criteria != '\0') {
1649 sasprintf(&pattern, "(?i)%s", criteria);
1650 match->class = regex_new(pattern);
1652 printf(" class = %s\n", criteria);
1656 /* Compatibility with older versions: If the assignment target starts
1657 * with ~, we create the equivalent of:
1659 * for_window [class="foo"] floating enable
1661 if (*workspace == '~') {
1663 if (*workspace == '\0') {
1664 /* This assignment was *only* for floating */
1665 assignment->type = A_COMMAND;
1666 assignment->dest.command = sstrdup("floating enable");
1667 TAILQ_INSERT_TAIL(&assignments, assignment, assignments);
1670 /* Create a new assignment and continue afterwards */
1671 Assignment *floating = scalloc(sizeof(Assignment));
1672 match_copy(&(floating->match), match);
1673 floating->type = A_COMMAND;
1674 floating->dest.command = sstrdup("floating enable");
1675 TAILQ_INSERT_TAIL(&assignments, floating, assignments);
1679 assignment->type = A_TO_WORKSPACE;
1680 assignment->dest.workspace = workspace;
1681 TAILQ_INSERT_TAIL(&assignments, assignment, assignments);
1683 | TOKASSIGN match STR
1685 if (match_is_empty(¤t_match)) {
1686 ELOG("Match is empty, ignoring this assignment\n");
1689 printf("new assignment, using above criteria, to workspace %s\n", $3);
1690 Assignment *assignment = scalloc(sizeof(Assignment));
1691 assignment->match = current_match;
1692 assignment->type = A_TO_WORKSPACE;
1693 assignment->dest.workspace = $3;
1694 TAILQ_INSERT_TAIL(&assignments, assignment, assignments);
1706 config.ipc_socket_path = $2;
1713 config.restart_state_path = $2;
1718 TOKEXEC optional_no_startup_id STR
1720 struct Autostart *new = smalloc(sizeof(struct Autostart));
1722 new->no_startup_id = $2;
1723 TAILQ_INSERT_TAIL(&autostarts, new, autostarts);
1728 TOKEXEC_ALWAYS optional_no_startup_id STR
1730 struct Autostart *new = smalloc(sizeof(struct Autostart));
1732 new->no_startup_id = $2;
1733 TAILQ_INSERT_TAIL(&autostarts_always, new, autostarts_always);
1737 optional_no_startup_id:
1738 /* empty */ { $$ = false; }
1739 | TOK_NO_STARTUP_ID { $$ = true; }
1745 ELOG("The terminal option is DEPRECATED and has no effect. "
1746 "Please remove it from your configuration file.\n");
1753 config.font = load_font($2, true);
1754 set_font(&config.font);
1755 printf("font %s\n", $2);
1762 TOKSINGLECOLOR colorpixel
1764 uint32_t *dest = $1;
1770 TOKCOLOR colorpixel colorpixel colorpixel
1772 struct Colortriple *dest = $1;
1775 dest->background = $3;
1778 | TOKCOLOR colorpixel colorpixel colorpixel colorpixel
1780 struct Colortriple *dest = $1;
1783 dest->background = $3;
1785 dest->indicator = $5;
1792 $$ = get_colorpixel($1);
1799 /* NULL */ { $$ = 0; }
1801 | binding_modifiers '+' binding_modifier { $$ = $1 | $3; }
1802 | binding_modifiers '+' { $$ = $1; }
1806 MODIFIER { $$ = $1; }
1807 | TOKCONTROL { $$ = BIND_CONTROL; }
1808 | TOKSHIFT { $$ = BIND_SHIFT; }
1811 popup_during_fullscreen:
1812 TOK_POPUP_DURING_FULLSCREEN popup_setting
1814 DLOG("popup_during_fullscreen setting: %d\n", $2);
1815 config.popup_during_fullscreen = $2;
1820 TOK_IGNORE { $$ = PDF_IGNORE; }
1821 | TOK_LEAVE_FULLSCREEN { $$ = PDF_LEAVE_FULLSCREEN; }