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 pixel", strlen("border pixel")) == 0 ||
112 strncasecmp(bind, "border borderless", strlen("border borderless")) == 0 ||
113 strncasecmp(bind, "--no-startup-id", strlen("--no-startup-id")) == 0 ||
114 strncasecmp(bind, "bar", strlen("bar")) == 0) {
115 printf("deciding for version 4 due to this line: %.*s\n", (int)(walk-line), line);
121 /* advance to the next line */
130 * Calls i3-migrate-config-to-v4 to migrate a configuration file (input
133 * Returns the converted config file or NULL if there was an error (for
134 * example the script could not be found in $PATH or the i3 executable’s
138 static char *migrate_config(char *input, off_t size) {
142 if (pipe(writepipe) != 0 ||
143 pipe(readpipe) != 0) {
144 warn("migrate_config: Could not create pipes");
150 warn("Could not fork()");
156 /* close writing end of writepipe, connect reading side to stdin */
158 dup2(writepipe[0], 0);
160 /* close reading end of readpipe, connect writing side to stdout */
162 dup2(readpipe[1], 1);
164 static char *argv[] = {
165 NULL, /* will be replaced by the executable path */
168 exec_i3_utility("i3-migrate-config-to-v4", argv);
173 /* close reading end of the writepipe (connected to the script’s stdin) */
176 /* write the whole config file to the pipe, the script will read everything
180 while (written < size) {
181 if ((ret = write(writepipe[1], input + written, size - written)) < 0) {
182 warn("Could not write to pipe");
189 /* close writing end of the readpipe (connected to the script’s stdout) */
192 /* read the script’s output */
193 int conv_size = 65535;
194 char *converted = malloc(conv_size);
197 if (read_bytes == conv_size) {
199 converted = realloc(converted, conv_size);
201 ret = read(readpipe[0], converted + read_bytes, conv_size - read_bytes);
203 warn("Cannot read from pipe");
210 /* get the returncode */
213 if (!WIFEXITED(status)) {
214 fprintf(stderr, "Child did not terminate normally, using old config file (will lead to broken behaviour)\n");
218 int returncode = WEXITSTATUS(status);
219 if (returncode != 0) {
220 fprintf(stderr, "Migration process exit code was != 0\n");
221 if (returncode == 2) {
222 fprintf(stderr, "could not start the migration script\n");
223 /* TODO: script was not found. tell the user to fix his system or create a v4 config */
224 } else if (returncode == 1) {
225 fprintf(stderr, "This already was a v4 config. Please add the following line to your config file:\n");
226 fprintf(stderr, "# i3 config file (v4)\n");
227 /* TODO: nag the user with a message to include a hint for i3 in his config file */
236 * Handler which will be called when we get a SIGCHLD for the nagbar, meaning
237 * it exited (or could not be started, depending on the exit code).
240 static void nagbar_exited(EV_P_ ev_child *watcher, int revents) {
241 ev_child_stop(EV_A_ watcher);
243 if (unlink(edit_script_path) != 0)
244 warn("Could not delete temporary i3-nagbar script %s", edit_script_path);
245 if (unlink(pager_script_path) != 0)
246 warn("Could not delete temporary i3-nagbar script %s", pager_script_path);
248 if (!WIFEXITED(watcher->rstatus)) {
249 fprintf(stderr, "ERROR: i3-nagbar did not exit normally.\n");
253 int exitcode = WEXITSTATUS(watcher->rstatus);
254 printf("i3-nagbar process exited with status %d\n", exitcode);
256 fprintf(stderr, "ERROR: i3-nagbar could not be found. Is it correctly installed on your system?\n");
259 configerror_pid = -1;
262 /* We need ev >= 4 for the following code. Since it is not *that* important (it
263 * only makes sure that there are no i3-nagbar instances left behind) we still
264 * support old systems with libev 3. */
265 #if EV_VERSION_MAJOR >= 4
267 * Cleanup handler. Will be called when i3 exits. Kills i3-nagbar with signal
268 * SIGKILL (9) to make sure there are no left-over i3-nagbar processes.
271 static void nagbar_cleanup(EV_P_ ev_cleanup *watcher, int revent) {
272 if (configerror_pid != -1) {
273 LOG("Sending SIGKILL (9) to i3-nagbar with PID %d\n", configerror_pid);
274 kill(configerror_pid, SIGKILL);
280 * Writes the given command as a shell script to path.
281 * Returns true unless something went wrong.
284 static bool write_nagbar_script(const char *path, const char *command) {
285 int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IXUSR);
287 warn("Could not create temporary script to store the nagbar command");
290 write(fd, "#!/bin/sh\n", strlen("#!/bin/sh\n"));
291 write(fd, command, strlen(command));
297 * Starts an i3-nagbar process which alerts the user that his configuration
298 * file contains one or more errors. Also offers two buttons: One to launch an
299 * $EDITOR on the config file and another one to launch a $PAGER on the error
303 static void start_configerror_nagbar(const char *config_path) {
304 if (only_check_config)
307 fprintf(stderr, "Starting i3-nagbar due to configuration errors\n");
309 /* We need to create a custom script containing our actual command
310 * since not every terminal emulator which is contained in
311 * i3-sensible-terminal supports -e with multiple arguments (and not
312 * all of them support -e with one quoted argument either).
314 * NB: The paths need to be unique, that is, don’t assume users close
315 * their nagbars at any point in time (and they still need to work).
317 edit_script_path = get_process_filename("nagbar-cfgerror-edit");
318 pager_script_path = get_process_filename("nagbar-cfgerror-pager");
320 configerror_pid = fork();
321 if (configerror_pid == -1) {
322 warn("Could not fork()");
327 if (configerror_pid == 0) {
328 char *edit_command, *pager_command;
329 sasprintf(&edit_command, "i3-sensible-editor \"%s\" && i3-msg reload\n", config_path);
330 sasprintf(&pager_command, "i3-sensible-pager \"%s\"\n", errorfilename);
331 if (!write_nagbar_script(edit_script_path, edit_command) ||
332 !write_nagbar_script(pager_script_path, pager_command))
337 sasprintf(&editaction, "i3-sensible-terminal -e \"%s\"", edit_script_path);
338 sasprintf(&pageraction, "i3-sensible-terminal -e \"%s\"", pager_script_path);
340 NULL, /* will be replaced by the executable path */
342 (context->has_errors ? "error" : "warning"),
344 (context->has_errors ?
345 "You have an error in your i3 config file!" :
346 "Your config is outdated. Please fix the warnings to make sure everything works."),
350 (errorfilename ? "-b" : NULL),
351 (context->has_errors ? "show errors" : "show warnings"),
355 exec_i3_utility("i3-nagbar", argv);
359 /* install a child watcher */
360 ev_child *child = smalloc(sizeof(ev_child));
361 ev_child_init(child, &nagbar_exited, configerror_pid, 0);
362 ev_child_start(main_loop, child);
364 /* We need ev >= 4 for the following code. Since it is not *that* important (it
365 * only makes sure that there are no i3-nagbar instances left behind) we still
366 * support old systems with libev 3. */
367 #if EV_VERSION_MAJOR >= 4
368 /* install a cleanup watcher (will be called when i3 exits and i3-nagbar is
370 ev_cleanup *cleanup = smalloc(sizeof(ev_cleanup));
371 ev_cleanup_init(cleanup, nagbar_cleanup);
372 ev_cleanup_start(main_loop, cleanup);
377 * Kills the configerror i3-nagbar process, if any.
379 * Called when reloading/restarting.
381 * If wait_for_it is set (restarting), this function will waitpid(), otherwise,
382 * ev is assumed to handle it (reloading).
385 void kill_configerror_nagbar(bool wait_for_it) {
386 if (configerror_pid == -1)
389 if (kill(configerror_pid, SIGTERM) == -1)
390 warn("kill(configerror_nagbar) failed");
395 /* When restarting, we don’t enter the ev main loop anymore and after the
396 * exec(), our old pid is no longer watched. So, ev won’t handle SIGCHLD
397 * for us and we would end up with a <defunct> process. Therefore we
399 waitpid(configerror_pid, NULL, 0);
403 * Checks for duplicate key bindings (the same keycode or keysym is configured
404 * more than once). If a duplicate binding is found, a message is printed to
405 * stderr and the has_errors variable is set to true, which will start
409 static void check_for_duplicate_bindings(struct context *context) {
410 Binding *bind, *current;
411 TAILQ_FOREACH(current, bindings, bindings) {
412 TAILQ_FOREACH(bind, bindings, bindings) {
413 /* Abort when we reach the current keybinding, only check the
418 /* Check if one is using keysym while the other is using bindsym.
420 /* XXX: It should be checked at a later place (when translating the
421 * keysym to keycodes) if there are any duplicates */
422 if ((bind->symbol == NULL && current->symbol != NULL) ||
423 (bind->symbol != NULL && current->symbol == NULL))
426 /* If bind is NULL, current has to be NULL, too (see above).
427 * If the keycodes differ, it can't be a duplicate. */
428 if (bind->symbol != NULL &&
429 strcasecmp(bind->symbol, current->symbol) != 0)
432 /* Check if the keycodes or modifiers are different. If so, they
433 * can't be duplicate */
434 if (bind->keycode != current->keycode ||
435 bind->mods != current->mods ||
436 bind->release != current->release)
439 context->has_errors = true;
440 if (current->keycode != 0) {
441 ELOG("Duplicate keybinding in config file:\n modmask %d with keycode %d, command \"%s\"\n",
442 current->mods, current->keycode, current->command);
444 ELOG("Duplicate keybinding in config file:\n modmask %d with keysym %s, command \"%s\"\n",
445 current->mods, current->symbol, current->command);
451 static void migrate_i3bar_exec(struct Autostart *exec) {
452 ELOG("**********************************************************************\n");
453 ELOG("IGNORING exec command: %s\n", exec->command);
454 ELOG("It contains \"i3bar\". Since i3 v4.1, i3bar will be automatically started\n");
455 ELOG("for each 'bar' configuration block in your i3 config. Please remove the exec\n");
456 ELOG("line and add the following to your i3 config:\n");
459 ELOG(" status_command i3status\n");
461 ELOG("**********************************************************************\n");
463 /* Generate a dummy bar configuration */
464 Barconfig *bar_config = scalloc(sizeof(Barconfig));
465 /* The hard-coded ID is not a problem. It does not conflict with the
466 * auto-generated bar IDs and having multiple hard-coded IDs is irrelevant
467 * – they all just contain status_command = i3status */
468 bar_config->id = sstrdup("migrate-bar");
469 bar_config->status_command = sstrdup("i3status");
470 TAILQ_INSERT_TAIL(&barconfigs, bar_config, configs);
472 /* Trigger an i3-nagbar */
473 context->has_warnings = true;
476 void parse_file(const char *f) {
477 SLIST_HEAD(variables_head, Variable) variables = SLIST_HEAD_INITIALIZER(&variables);
478 int fd, ret, read_bytes = 0;
482 char buffer[1026], key[512], value[512];
484 if ((fd = open(f, O_RDONLY)) == -1)
485 die("Could not open configuration file: %s\n", strerror(errno));
487 if (fstat(fd, &stbuf) == -1)
488 die("Could not fstat file: %s\n", strerror(errno));
490 buf = scalloc((stbuf.st_size + 1) * sizeof(char));
491 while (read_bytes < stbuf.st_size) {
492 if ((ret = read(fd, buf + read_bytes, (stbuf.st_size - read_bytes))) < 0)
493 die("Could not read(): %s\n", strerror(errno));
497 if (lseek(fd, 0, SEEK_SET) == (off_t)-1)
498 die("Could not lseek: %s\n", strerror(errno));
500 if ((fstr = fdopen(fd, "r")) == NULL)
501 die("Could not fdopen: %s\n", strerror(errno));
503 while (!feof(fstr)) {
504 if (fgets(buffer, 1024, fstr) == NULL) {
507 die("Could not read configuration file\n");
510 /* sscanf implicitly strips whitespace. Also, we skip comments and empty lines. */
511 if (sscanf(buffer, "%s %[^\n]", key, value) < 1 ||
512 key[0] == '#' || strlen(key) < 3)
515 if (strcasecmp(key, "set") == 0) {
516 if (value[0] != '$') {
517 ELOG("Malformed variable assignment, name has to start with $\n");
521 /* get key/value for this variable */
522 char *v_key = value, *v_value;
523 if (strstr(value, " ") == NULL && strstr(value, "\t") == NULL) {
524 ELOG("Malformed variable assignment, need a value\n");
528 if (!(v_value = strstr(value, " ")))
529 v_value = strstr(value, "\t");
532 while (*v_value == '\t' || *v_value == ' ')
535 struct Variable *new = scalloc(sizeof(struct Variable));
536 new->key = sstrdup(v_key);
537 new->value = sstrdup(v_value);
538 SLIST_INSERT_HEAD(&variables, new, variables);
539 DLOG("Got new variable %s = %s\n", v_key, v_value);
545 /* For every custom variable, see how often it occurs in the file and
546 * how much extra bytes it requires when replaced. */
547 struct Variable *current, *nearest;
549 /* We need to copy the buffer because we need to invalidate the
550 * variables (otherwise we will count them twice, which is bad when
551 * 'extra' is negative) */
552 char *bufcopy = sstrdup(buf);
553 SLIST_FOREACH(current, &variables, variables) {
554 int extra = (strlen(current->value) - strlen(current->key));
557 next < (bufcopy + stbuf.st_size) &&
558 (next = strcasestr(next, current->key)) != NULL;
559 next += strlen(current->key)) {
561 extra_bytes += extra;
566 /* Then, allocate a new buffer and copy the file over to the new one,
567 * but replace occurences of our variables */
568 char *walk = buf, *destwalk;
569 char *new = smalloc((stbuf.st_size + extra_bytes + 1) * sizeof(char));
571 while (walk < (buf + stbuf.st_size)) {
572 /* Find the next variable */
573 SLIST_FOREACH(current, &variables, variables)
574 current->next_match = strcasestr(walk, current->key);
576 int distance = stbuf.st_size;
577 SLIST_FOREACH(current, &variables, variables) {
578 if (current->next_match == NULL)
580 if ((current->next_match - walk) < distance) {
581 distance = (current->next_match - walk);
585 if (nearest == NULL) {
586 /* If there are no more variables, we just copy the rest */
587 strncpy(destwalk, walk, (buf + stbuf.st_size) - walk);
588 destwalk += (buf + stbuf.st_size) - walk;
592 /* Copy until the next variable, then copy its value */
593 strncpy(destwalk, walk, distance);
594 strncpy(destwalk + distance, nearest->value, strlen(nearest->value));
595 walk += distance + strlen(nearest->key);
596 destwalk += distance + strlen(nearest->value);
600 /* analyze the string to find out whether this is an old config file (3.x)
601 * or a new config file (4.x). If it’s old, we run the converter script. */
602 int version = detect_version(buf);
604 /* We need to convert this v3 configuration */
605 char *converted = migrate_config(new, stbuf.st_size);
606 if (converted != NULL) {
608 ELOG("****************************************************************\n");
609 ELOG("NOTE: Automatically converted configuration file from v3 to v4.\n");
611 ELOG("Please convert your config file to v4. You can use this command:\n");
612 ELOG(" mv %s %s.O\n", f, f);
613 ELOG(" i3-migrate-config-to-v4 %s.O > %s\n", f, f);
614 ELOG("****************************************************************\n");
620 printf("**********************************************************************\n");
621 printf("ERROR: Could not convert config file. Maybe i3-migrate-config-to-v4\n");
622 printf("was not correctly installed on your system?\n");
623 printf("**********************************************************************\n");
628 /* now lex/parse it */
631 context = scalloc(sizeof(struct context));
632 context->filename = f;
634 if (yyparse() != 0) {
635 fprintf(stderr, "Could not parse configfile\n");
639 check_for_duplicate_bindings(context);
641 /* XXX: The following code will be removed in i3 v4.3 (three releases from
642 * now, as of 2011-10-22) */
643 /* Check for any exec or exec_always lines starting i3bar. We remove these
644 * and add a bar block instead. Additionally, a i3-nagbar warning (not an
645 * error) will be displayed so that users update their config file. */
646 struct Autostart *exec, *next;
647 for (exec = TAILQ_FIRST(&autostarts); exec; ) {
648 next = TAILQ_NEXT(exec, autostarts);
649 if (strstr(exec->command, "i3bar") != NULL) {
650 migrate_i3bar_exec(exec);
651 TAILQ_REMOVE(&autostarts, exec, autostarts);
656 for (exec = TAILQ_FIRST(&autostarts_always); exec; ) {
657 next = TAILQ_NEXT(exec, autostarts_always);
658 if (strstr(exec->command, "i3bar") != NULL) {
659 migrate_i3bar_exec(exec);
660 TAILQ_REMOVE(&autostarts_always, exec, autostarts_always);
665 if (context->has_errors || context->has_warnings) {
666 ELOG("FYI: You are using i3 version " I3_VERSION "\n");
668 ELOG("Please convert your configfile first, then fix any remaining errors (see above).\n");
669 start_configerror_nagbar(f);
673 FREE(context->line_copy);
679 while (!SLIST_EMPTY(&variables)) {
680 current = SLIST_FIRST(&variables);
682 FREE(current->value);
683 SLIST_REMOVE_HEAD(&variables, variables);
691 %lex-param { struct context *context }
696 uint32_t *single_color;
697 struct Colortriple *color;
699 struct Binding *binding;
702 %token <number> NUMBER "<number>"
703 %token <string> WORD "<word>"
704 %token <string> STR "<string>"
705 %token <string> STR_NG "<string (non-greedy)>"
706 %token <string> HEXCOLOR "#<hex>"
707 %token <string> OUTPUT "<RandR output>"
710 %token TOKCOMMENT "<comment>"
711 %token TOKFONT "font"
712 %token TOKBINDSYM "bindsym"
713 %token <number> MODIFIER "<modifier>"
714 %token TOKCONTROL "control"
715 %token TOKSHIFT "shift"
716 %token TOKFLOATING_MODIFIER "floating_modifier"
717 %token TOKFLOATING_MAXIMUM_SIZE "floating_maximum_size"
718 %token TOKFLOATING_MINIMUM_SIZE "floating_minimum_size"
719 %token <string> QUOTEDSTRING "<quoted string>"
720 %token TOKWORKSPACE "workspace"
721 %token TOKOUTPUT "output"
722 %token TOKASSIGN "assign"
724 %token TOKIPCSOCKET "ipc_socket"
725 %token TOKRESTARTSTATE "restart_state"
726 %token TOKEXEC "exec"
727 %token TOKEXEC_ALWAYS "exec_always"
728 %token <single_color> TOKSINGLECOLOR
729 %token <color> TOKCOLOR
731 %token TOKMODE "mode"
732 %token TOK_TIME_MS "ms"
734 %token TOK_ORIENTATION "default_orientation"
735 %token TOK_HORIZ "horizontal"
736 %token TOK_VERT "vertical"
737 %token TOK_AUTO "auto"
738 %token TOK_WORKSPACE_LAYOUT "workspace_layout"
739 %token TOKNEWWINDOW "new_window"
740 %token TOKNEWFLOAT "new_float"
741 %token TOK_NORMAL "normal"
742 %token TOK_NONE "none"
743 %token TOK_PIXEL "pixel"
744 %token TOK_1PIXEL "1pixel"
745 %token TOK_HIDE_EDGE_BORDERS "hide_edge_borders"
746 %token TOK_BOTH "both"
747 %token TOKFOCUSFOLLOWSMOUSE "focus_follows_mouse"
748 %token TOK_FORCE_FOCUS_WRAPPING "force_focus_wrapping"
749 %token TOK_FORCE_XINERAMA "force_xinerama"
750 %token TOK_FAKE_OUTPUTS "fake_outputs"
751 %token TOK_WORKSPACE_AUTO_BAF "workspace_auto_back_and_forth"
752 %token TOK_WORKSPACE_URGENCY_TIMER "force_display_urgency_hint"
753 %token TOKWORKSPACEBAR "workspace_bar"
754 %token TOK_DEFAULT "default"
755 %token TOK_STACKING "stacking"
756 %token TOK_TABBED "tabbed"
757 %token <number> TOKSTACKLIMIT "stack-limit"
758 %token TOK_POPUP_DURING_FULLSCREEN "popup_during_fullscreen"
759 %token TOK_IGNORE "ignore"
760 %token TOK_LEAVE_FULLSCREEN "leave_fullscreen"
761 %token TOK_FOR_WINDOW "for_window"
763 %token TOK_BAR_OUTPUT "output (bar)"
764 %token TOK_BAR_TRAY_OUTPUT "tray_output"
765 %token TOK_BAR_SOCKET_PATH "socket_path"
766 %token TOK_BAR_MODE "mode (bar)"
767 %token TOK_BAR_HIDE "hide"
768 %token TOK_BAR_DOCK "dock"
769 %token TOK_BAR_MODIFIER "modifier (bar)"
770 %token TOK_BAR_CONTROL "shift (bar)"
771 %token TOK_BAR_SHIFT "control (bar)"
772 %token TOK_BAR_MOD1 "Mod1"
773 %token TOK_BAR_MOD2 "Mod2"
774 %token TOK_BAR_MOD3 "Mod3"
775 %token TOK_BAR_MOD4 "Mod4"
776 %token TOK_BAR_MOD5 "Mod5"
777 %token TOK_BAR_POSITION "position"
778 %token TOK_BAR_BOTTOM "bottom"
779 %token TOK_BAR_TOP "top"
780 %token TOK_BAR_STATUS_COMMAND "status_command"
781 %token TOK_BAR_I3BAR_COMMAND "i3bar_command"
782 %token TOK_BAR_FONT "font (bar)"
783 %token TOK_BAR_WORKSPACE_BUTTONS "workspace_buttons"
784 %token TOK_BAR_VERBOSE "verbose"
785 %token TOK_BAR_COLORS "colors"
786 %token TOK_BAR_COLOR_BACKGROUND "background"
787 %token TOK_BAR_COLOR_STATUSLINE "statusline"
788 %token TOK_BAR_COLOR_FOCUSED_WORKSPACE "focused_workspace"
789 %token TOK_BAR_COLOR_ACTIVE_WORKSPACE "active_workspace"
790 %token TOK_BAR_COLOR_INACTIVE_WORKSPACE "inactive_workspace"
791 %token TOK_BAR_COLOR_URGENT_WORKSPACE "urgent_workspace"
792 %token TOK_NO_STARTUP_ID "--no-startup-id"
793 %token TOK_RELEASE "--release"
795 %token TOK_MARK "mark"
796 %token TOK_CLASS "class"
797 %token TOK_INSTANCE "instance"
798 %token TOK_WINDOW_ROLE "window_role"
800 %token TOK_CON_ID "con_id"
801 %token TOK_TITLE "title"
802 %token TOK_URGENT "urgent"
804 %type <binding> binding
805 %type <binding> bindcode
806 %type <binding> bindsym
807 %type <number> binding_modifiers
808 %type <number> binding_modifier
809 %type <number> direction
810 %type <number> layout_mode
811 %type <number> border_style
812 %type <number> new_window
813 %type <number> hide_edge_borders
814 %type <number> edge_hiding_mode
815 %type <number> new_float
816 %type <number> colorpixel
818 %type <number> popup_setting
819 %type <number> bar_position_position
820 %type <number> bar_mode_mode
821 %type <number> bar_modifier_modifier
822 %type <number> optional_no_startup_id
823 %type <number> optional_border_width
824 %type <number> optional_release
825 %type <string> command
826 %type <string> word_or_number
827 %type <string> duration
828 %type <string> qstring_or_number
829 %type <string> optional_workspace_name
830 %type <string> workspace_name
831 %type <string> window_class
845 | floating_maximum_size
846 | floating_minimum_size
853 | focus_follows_mouse
854 | force_focus_wrapping
857 | force_display_urgency_hint
858 | workspace_back_and_forth
871 | popup_during_fullscreen
885 TAILQ_INSERT_TAIL(bindings, $1, bindings);
890 TOKBINDCODE bindcode { $$ = $2; }
891 | TOKBINDSYM bindsym { $$ = $2; }
895 optional_release binding_modifiers NUMBER command
897 DLOG("bindcode: release = %d, mod = %d, key = %d, command = %s\n", $1, $2, $3, $4);
898 Binding *new = scalloc(sizeof(Binding));
910 optional_release binding_modifiers word_or_number command
912 DLOG("bindsym: release = %d, mod = %d, key = %s, command = %s\n", $1, $2, $3, $4);
913 Binding *new = scalloc(sizeof(Binding));
925 /* empty */ { $$ = B_UPON_KEYPRESS; }
926 | TOK_RELEASE { $$ = B_UPON_KEYRELEASE; }
930 TOK_FOR_WINDOW match command
932 if (match_is_empty(¤t_match)) {
933 ELOG("Match is empty, ignoring this for_window statement\n");
936 printf("\t should execute command %s for the criteria mentioned above\n", $3);
937 Assignment *assignment = scalloc(sizeof(Assignment));
938 assignment->type = A_COMMAND;
939 assignment->match = current_match;
940 assignment->dest.command = $3;
941 TAILQ_INSERT_TAIL(&assignments, assignment, assignments);
946 | matchstart criteria matchend
948 printf("match parsed\n");
956 match_init(¤t_match);
963 printf("match specification finished\n");
975 printf("criteria: class = %s\n", $3);
976 current_match.class = regex_new($3);
979 | TOK_INSTANCE '=' STR
981 printf("criteria: instance = %s\n", $3);
982 current_match.instance = regex_new($3);
985 | TOK_WINDOW_ROLE '=' STR
987 printf("criteria: window_role = %s\n", $3);
988 current_match.role = regex_new($3);
993 printf("criteria: id = %s\n", $3);
995 long parsed = strtol($3, &end, 10);
996 if (parsed == LONG_MIN ||
997 parsed == LONG_MAX ||
999 (end && *end != '\0')) {
1000 ELOG("Could not parse con id \"%s\"\n", $3);
1002 current_match.con_id = (Con*)parsed;
1003 printf("id as int = %p\n", current_match.con_id);
1008 printf("criteria: window id = %s\n", $3);
1010 long parsed = strtol($3, &end, 10);
1011 if (parsed == LONG_MIN ||
1012 parsed == LONG_MAX ||
1014 (end && *end != '\0')) {
1015 ELOG("Could not parse window id \"%s\"\n", $3);
1017 current_match.id = parsed;
1018 printf("window id as int = %d\n", current_match.id);
1023 printf("criteria: mark = %s\n", $3);
1024 current_match.mark = regex_new($3);
1029 printf("criteria: title = %s\n", $3);
1030 current_match.title = regex_new($3);
1033 | TOK_URGENT '=' STR
1035 printf("criteria: urgent = %s\n", $3);
1036 if (strcasecmp($3, "latest") == 0 ||
1037 strcasecmp($3, "newest") == 0 ||
1038 strcasecmp($3, "recent") == 0 ||
1039 strcasecmp($3, "last") == 0) {
1040 current_match.urgent = U_LATEST;
1041 } else if (strcasecmp($3, "oldest") == 0 ||
1042 strcasecmp($3, "first") == 0) {
1043 current_match.urgent = U_OLDEST;
1051 | NUMBER { sasprintf(&$$, "%d", $1); }
1058 sasprintf(&$$, "%d", $1);
1063 NUMBER { sasprintf(&$$, "%d", $1); }
1064 | NUMBER TOK_TIME_MS { sasprintf(&$$, "%d", $1); }
1068 TOKMODE QUOTEDSTRING '{' modelines '}'
1070 if (strcasecmp($2, "default") == 0) {
1071 printf("You cannot use the name \"default\" for your mode\n");
1074 printf("\t now in mode %s\n", $2);
1075 printf("\t current bindings = %p\n", current_bindings);
1077 TAILQ_FOREACH(binding, current_bindings, bindings) {
1078 printf("got binding on mods %d, keycode %d, symbol %s, command %s\n",
1079 binding->mods, binding->keycode, binding->symbol, binding->command);
1082 struct Mode *mode = scalloc(sizeof(struct Mode));
1084 mode->bindings = current_bindings;
1085 current_bindings = NULL;
1086 SLIST_INSERT_HEAD(&modes, mode, modes);
1093 | modelines modeline
1100 if (current_bindings == NULL) {
1101 current_bindings = scalloc(sizeof(struct bindings_head));
1102 TAILQ_INIT(current_bindings);
1105 TAILQ_INSERT_TAIL(current_bindings, $1, bindings);
1110 TOK_BAR '{' barlines '}'
1112 printf("\t new bar configuration finished, saving.\n");
1113 /* Generate a unique ID for this bar */
1114 current_bar.id = sstrdup("bar-XXXXXX");
1115 /* This works similar to mktemp in that it replaces the last six X with
1116 * random letters, but without the restriction that the given buffer
1117 * has to contain a valid path name. */
1118 char *x = current_bar.id + strlen("bar-");
1119 while (*x != '\0') {
1120 *(x++) = (rand() % 26) + 'a';
1123 /* If no font was explicitly set, we use the i3 font as default */
1124 if (!current_bar.font && font_pattern)
1125 current_bar.font = sstrdup(font_pattern);
1127 /* Copy the current (static) structure into a dynamically allocated
1128 * one, then cleanup our static one. */
1129 Barconfig *bar_config = scalloc(sizeof(Barconfig));
1130 memcpy(bar_config, ¤t_bar, sizeof(Barconfig));
1131 TAILQ_INSERT_TAIL(&barconfigs, bar_config, configs);
1133 memset(¤t_bar, '\0', sizeof(Barconfig));
1144 | bar_status_command
1152 | bar_workspace_buttons
1156 | bar_color_background
1157 | bar_color_statusline
1158 | bar_color_focused_workspace
1159 | bar_color_active_workspace
1160 | bar_color_inactive_workspace
1161 | bar_color_urgent_workspace
1165 TOK_BAR_STATUS_COMMAND STR
1167 DLOG("should add status command %s\n", $2);
1168 FREE(current_bar.status_command);
1169 current_bar.status_command = $2;
1174 TOK_BAR_I3BAR_COMMAND STR
1176 DLOG("should add i3bar_command %s\n", $2);
1177 FREE(current_bar.i3bar_command);
1178 current_bar.i3bar_command = $2;
1185 DLOG("bar output %s\n", $2);
1186 int new_outputs = current_bar.num_outputs + 1;
1187 current_bar.outputs = srealloc(current_bar.outputs, sizeof(char*) * new_outputs);
1188 current_bar.outputs[current_bar.num_outputs] = $2;
1189 current_bar.num_outputs = new_outputs;
1194 TOK_BAR_TRAY_OUTPUT STR
1196 DLOG("tray %s\n", $2);
1197 FREE(current_bar.tray_output);
1198 current_bar.tray_output = $2;
1203 TOK_BAR_POSITION bar_position_position
1205 DLOG("position %d\n", $2);
1206 current_bar.position = $2;
1210 bar_position_position:
1211 TOK_BAR_TOP { $$ = P_TOP; }
1212 | TOK_BAR_BOTTOM { $$ = P_BOTTOM; }
1216 TOK_BAR_MODE bar_mode_mode
1218 DLOG("mode %d\n", $2);
1219 current_bar.mode = $2;
1224 TOK_BAR_HIDE { $$ = M_HIDE; }
1225 | TOK_BAR_DOCK { $$ = M_DOCK; }
1229 TOK_BAR_MODIFIER bar_modifier_modifier
1231 DLOG("modifier %d\n", $2);
1232 current_bar.modifier = $2;
1235 bar_modifier_modifier:
1236 TOK_BAR_CONTROL { $$ = M_CONTROL; }
1237 | TOK_BAR_SHIFT { $$ = M_SHIFT; }
1238 | TOK_BAR_MOD1 { $$ = M_MOD1; }
1239 | TOK_BAR_MOD2 { $$ = M_MOD2; }
1240 | TOK_BAR_MOD3 { $$ = M_MOD3; }
1241 | TOK_BAR_MOD4 { $$ = M_MOD4; }
1242 | TOK_BAR_MOD5 { $$ = M_MOD5; }
1248 DLOG("font %s\n", $2);
1249 FREE(current_bar.font);
1250 current_bar.font = $2;
1254 bar_workspace_buttons:
1255 TOK_BAR_WORKSPACE_BUTTONS bool
1257 DLOG("workspace_buttons = %d\n", $2);
1258 /* We store this inverted to make the default setting right when
1259 * initializing the struct with zero. */
1260 current_bar.hide_workspace_buttons = !($2);
1265 TOK_BAR_VERBOSE bool
1267 DLOG("verbose = %d\n", $2);
1268 current_bar.verbose = $2;
1273 TOK_BAR_SOCKET_PATH STR
1275 DLOG("socket_path = %s\n", $2);
1276 FREE(current_bar.socket_path);
1277 current_bar.socket_path = $2;
1282 TOK_BAR_COLORS '{' barlines '}'
1284 /* At the moment, the TOK_BAR_COLORS token is only to make the config
1285 * friendlier for humans. We might change this in the future if it gets
1290 bar_color_background:
1291 TOK_BAR_COLOR_BACKGROUND HEXCOLOR
1293 DLOG("background = %s\n", $2);
1294 current_bar.colors.background = $2;
1298 bar_color_statusline:
1299 TOK_BAR_COLOR_STATUSLINE HEXCOLOR
1301 DLOG("statusline = %s\n", $2);
1302 current_bar.colors.statusline = $2;
1306 bar_color_focused_workspace:
1307 TOK_BAR_COLOR_FOCUSED_WORKSPACE HEXCOLOR HEXCOLOR
1309 /* Old syntax: text / background */
1310 DLOG("focused_ws = %s, %s (old)\n", $2, $3);
1311 current_bar.colors.focused_workspace_bg = $3;
1312 current_bar.colors.focused_workspace_text = $2;
1314 | TOK_BAR_COLOR_FOCUSED_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR
1316 /* New syntax: border / background / text */
1317 DLOG("focused_ws = %s, %s and %s\n", $2, $3, $4);
1318 current_bar.colors.focused_workspace_border = $2;
1319 current_bar.colors.focused_workspace_bg = $3;
1320 current_bar.colors.focused_workspace_text = $4;
1324 bar_color_active_workspace:
1325 TOK_BAR_COLOR_ACTIVE_WORKSPACE HEXCOLOR HEXCOLOR
1327 /* Old syntax: text / background */
1328 DLOG("active_ws = %s, %s (old)\n", $2, $3);
1329 current_bar.colors.active_workspace_bg = $3;
1330 current_bar.colors.active_workspace_text = $2;
1332 | TOK_BAR_COLOR_ACTIVE_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR
1334 /* New syntax: border / background / text */
1335 DLOG("active_ws = %s, %s and %s\n", $2, $3, $4);
1336 current_bar.colors.active_workspace_border = $2;
1337 current_bar.colors.active_workspace_bg = $3;
1338 current_bar.colors.active_workspace_text = $4;
1342 bar_color_inactive_workspace:
1343 TOK_BAR_COLOR_INACTIVE_WORKSPACE HEXCOLOR HEXCOLOR
1345 /* Old syntax: text / background */
1346 DLOG("inactive_ws = %s, %s (old)\n", $2, $3);
1347 current_bar.colors.inactive_workspace_bg = $3;
1348 current_bar.colors.inactive_workspace_text = $2;
1350 | TOK_BAR_COLOR_INACTIVE_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR
1352 DLOG("inactive_ws = %s, %s and %s\n", $2, $3, $4);
1353 current_bar.colors.inactive_workspace_border = $2;
1354 current_bar.colors.inactive_workspace_bg = $3;
1355 current_bar.colors.inactive_workspace_text = $4;
1359 bar_color_urgent_workspace:
1360 TOK_BAR_COLOR_URGENT_WORKSPACE HEXCOLOR HEXCOLOR
1362 /* Old syntax: text / background */
1363 DLOG("urgent_ws = %s, %s (old)\n", $2, $3);
1364 current_bar.colors.urgent_workspace_bg = $3;
1365 current_bar.colors.urgent_workspace_text = $2;
1367 | TOK_BAR_COLOR_URGENT_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR
1369 DLOG("urgent_ws = %s, %s and %s\n", $2, $3, $4);
1370 current_bar.colors.urgent_workspace_border = $2;
1371 current_bar.colors.urgent_workspace_bg = $3;
1372 current_bar.colors.urgent_workspace_text = $4;
1376 floating_maximum_size:
1377 TOKFLOATING_MAXIMUM_SIZE NUMBER WORD NUMBER
1379 printf("floating_maximum_width = %d\n", $2);
1380 printf("floating_maximum_height = %d\n", $4);
1381 config.floating_maximum_width = $2;
1382 config.floating_maximum_height = $4;
1386 floating_minimum_size:
1387 TOKFLOATING_MINIMUM_SIZE NUMBER WORD NUMBER
1389 printf("floating_minimum_width = %d\n", $2);
1390 printf("floating_minimum_height = %d\n", $4);
1391 config.floating_minimum_width = $2;
1392 config.floating_minimum_height = $4;
1397 TOKFLOATING_MODIFIER binding_modifiers
1399 DLOG("floating modifier = %d\n", $2);
1400 config.floating_modifier = $2;
1405 TOK_ORIENTATION direction
1407 DLOG("New containers should start with split direction %d\n", $2);
1408 config.default_orientation = $2;
1413 TOK_HORIZ { $$ = HORIZ; }
1414 | TOK_VERT { $$ = VERT; }
1415 | TOK_AUTO { $$ = NO_ORIENTATION; }
1419 TOK_WORKSPACE_LAYOUT layout_mode
1421 DLOG("new containers will be in mode %d\n", $2);
1422 config.default_layout = $2;
1425 /* We also need to change the layout of the already existing
1426 * workspaces here. Workspaces may exist at this point because
1427 * of the other directives which are modifying workspaces
1428 * (setting the preferred screen or name). While the workspace
1429 * objects are already created, they have never been used.
1430 * Thus, the user very likely awaits the default container mode
1431 * to trigger in this case, regardless of where it is inside
1432 * his configuration file. */
1434 TAILQ_FOREACH(ws, workspaces, workspaces) {
1435 if (ws->table == NULL)
1437 switch_layout_mode(global_conn,
1439 config.container_mode);
1443 | TOK_WORKSPACE_LAYOUT TOKSTACKLIMIT TOKSTACKLIMIT NUMBER
1445 DLOG("stack-limit %d with val %d\n", $3, $4);
1446 config.container_stack_limit = $3;
1447 config.container_stack_limit_value = $4;
1450 /* See the comment above */
1452 TAILQ_FOREACH(ws, workspaces, workspaces) {
1453 if (ws->table == NULL)
1455 Container *con = ws->table[0][0];
1456 con->stack_limit = config.container_stack_limit;
1457 con->stack_limit_value = config.container_stack_limit_value;
1464 TOK_DEFAULT { $$ = L_DEFAULT; }
1465 | TOK_STACKING { $$ = L_STACKED; }
1466 | TOK_TABBED { $$ = L_TABBED; }
1470 TOKNEWWINDOW border_style
1472 DLOG("new windows should start with border style %d\n", $2);
1473 config.default_border = $2;
1478 TOKNEWFLOAT border_style
1480 DLOG("new floating windows should start with border style %d\n", $2);
1481 config.default_floating_border = $2;
1486 TOK_NORMAL optional_border_width
1488 config.default_border_width = $2;
1493 config.default_border_width = 1;
1498 config.default_border_width = 0;
1501 | TOK_PIXEL optional_border_width
1503 config.default_border_width = $2;
1515 DLOG("checking word \"%s\"\n", $1);
1516 $$ = (strcasecmp($1, "yes") == 0 ||
1517 strcasecmp($1, "true") == 0 ||
1518 strcasecmp($1, "on") == 0 ||
1519 strcasecmp($1, "enable") == 0 ||
1520 strcasecmp($1, "active") == 0);
1525 TOK_HIDE_EDGE_BORDERS edge_hiding_mode
1527 DLOG("hide edge borders = %d\n", $2);
1528 config.hide_edge_borders = $2;
1533 TOK_NONE { $$ = ADJ_NONE; }
1534 | TOK_VERT { $$ = ADJ_LEFT_SCREEN_EDGE | ADJ_RIGHT_SCREEN_EDGE; }
1535 | TOK_HORIZ { $$ = ADJ_UPPER_SCREEN_EDGE | ADJ_LOWER_SCREEN_EDGE; }
1536 | TOK_BOTH { $$ = ADJ_LEFT_SCREEN_EDGE | ADJ_RIGHT_SCREEN_EDGE | ADJ_UPPER_SCREEN_EDGE | ADJ_LOWER_SCREEN_EDGE; }
1537 | bool { $$ = ($1 ? ADJ_LEFT_SCREEN_EDGE | ADJ_RIGHT_SCREEN_EDGE : ADJ_NONE); }
1540 focus_follows_mouse:
1541 TOKFOCUSFOLLOWSMOUSE bool
1543 DLOG("focus follows mouse = %d\n", $2);
1544 config.disable_focus_follows_mouse = !($2);
1548 force_focus_wrapping:
1549 TOK_FORCE_FOCUS_WRAPPING bool
1551 DLOG("force focus wrapping = %d\n", $2);
1552 config.force_focus_wrapping = $2;
1557 TOK_FORCE_XINERAMA bool
1559 DLOG("force xinerama = %d\n", $2);
1560 config.force_xinerama = $2;
1565 TOK_FAKE_OUTPUTS STR
1567 DLOG("fake outputs = %s\n", $2);
1568 config.fake_outputs = $2;
1572 workspace_back_and_forth:
1573 TOK_WORKSPACE_AUTO_BAF bool
1575 DLOG("automatic workspace back-and-forth = %d\n", $2);
1576 config.workspace_auto_back_and_forth = $2;
1580 force_display_urgency_hint:
1581 TOK_WORKSPACE_URGENCY_TIMER duration
1583 DLOG("workspace urgency_timer = %f\n", atoi($2) / 1000.0);
1584 config.workspace_urgency_timer = atoi($2) / 1000.0;
1589 TOKWORKSPACEBAR bool
1591 DLOG("workspace bar = %d\n", $2);
1592 config.disable_workspace_bar = !($2);
1597 TOKWORKSPACE qstring_or_number TOKOUTPUT OUTPUT optional_workspace_name
1602 ELOG("The old (v3) syntax workspace <number> output <output> <name> is deprecated.\n");
1603 ELOG("Please use the new syntax: workspace \"<workspace>\" output <output>\n");
1604 ELOG("In your case, the following should work:\n");
1605 ELOG(" workspace \"%s\" output %s\n", $5, $4);
1607 context->has_warnings = true;
1610 DLOG("Assigning workspace \"%s\" to output \"%s\"\n", ws_name, $4);
1611 /* Check for earlier assignments of the same workspace so that we
1612 * don’t have assignments of a single workspace to different
1614 struct Workspace_Assignment *assignment;
1615 bool duplicate = false;
1616 TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) {
1617 if (strcasecmp(assignment->name, ws_name) == 0) {
1618 ELOG("You have a duplicate workspace assignment for workspace \"%s\"\n",
1620 assignment->output = $4;
1625 assignment = scalloc(sizeof(struct Workspace_Assignment));
1626 assignment->name = ws_name;
1627 assignment->output = $4;
1628 TAILQ_INSERT_TAIL(&ws_assignments, assignment, ws_assignments);
1631 | TOKWORKSPACE NUMBER workspace_name
1635 DLOG("Invalid workspace assignment, workspace number %d out of range\n", ws_num);
1637 DLOG("workspace name to: %s\n", $3);
1639 if ($<string>3 != NULL) {
1640 workspace_set_name(workspace_get(ws_num - 1), $<string>3);
1648 optional_workspace_name:
1649 /* empty */ { $$ = NULL; }
1650 | workspace_name { $$ = $1; }
1654 QUOTEDSTRING { $$ = $1; }
1660 TOKASSIGN window_class STR
1662 /* This is the old, deprecated form of assignments. It’s provided for
1663 * compatibility in version (4.1, 4.2, 4.3) and will be removed
1664 * afterwards. It triggers an i3-nagbar warning starting from 4.1. */
1665 ELOG("You are using the old assign syntax (without criteria). "
1666 "Please see the User's Guide for the new syntax and fix "
1667 "your config file.\n");
1668 context->has_warnings = true;
1669 printf("assignment of %s to *%s*\n", $2, $3);
1670 char *workspace = $3;
1671 char *criteria = $2;
1673 Assignment *assignment = scalloc(sizeof(Assignment));
1674 Match *match = &(assignment->match);
1677 char *separator = NULL;
1678 if ((separator = strchr(criteria, '/')) != NULL) {
1679 *(separator++) = '\0';
1681 sasprintf(&pattern, "(?i)%s", separator);
1682 match->title = regex_new(pattern);
1684 printf(" title = %s\n", separator);
1686 if (*criteria != '\0') {
1688 sasprintf(&pattern, "(?i)%s", criteria);
1689 match->class = regex_new(pattern);
1691 printf(" class = %s\n", criteria);
1695 /* Compatibility with older versions: If the assignment target starts
1696 * with ~, we create the equivalent of:
1698 * for_window [class="foo"] floating enable
1700 if (*workspace == '~') {
1702 if (*workspace == '\0') {
1703 /* This assignment was *only* for floating */
1704 assignment->type = A_COMMAND;
1705 assignment->dest.command = sstrdup("floating enable");
1706 TAILQ_INSERT_TAIL(&assignments, assignment, assignments);
1709 /* Create a new assignment and continue afterwards */
1710 Assignment *floating = scalloc(sizeof(Assignment));
1711 match_copy(&(floating->match), match);
1712 floating->type = A_COMMAND;
1713 floating->dest.command = sstrdup("floating enable");
1714 TAILQ_INSERT_TAIL(&assignments, floating, assignments);
1718 assignment->type = A_TO_WORKSPACE;
1719 assignment->dest.workspace = workspace;
1720 TAILQ_INSERT_TAIL(&assignments, assignment, assignments);
1722 | TOKASSIGN match STR
1724 if (match_is_empty(¤t_match)) {
1725 ELOG("Match is empty, ignoring this assignment\n");
1728 printf("new assignment, using above criteria, to workspace %s\n", $3);
1729 Assignment *assignment = scalloc(sizeof(Assignment));
1730 assignment->match = current_match;
1731 assignment->type = A_TO_WORKSPACE;
1732 assignment->dest.workspace = $3;
1733 TAILQ_INSERT_TAIL(&assignments, assignment, assignments);
1745 config.ipc_socket_path = $2;
1752 config.restart_state_path = $2;
1757 TOKEXEC optional_no_startup_id STR
1759 struct Autostart *new = smalloc(sizeof(struct Autostart));
1761 new->no_startup_id = $2;
1762 TAILQ_INSERT_TAIL(&autostarts, new, autostarts);
1767 TOKEXEC_ALWAYS optional_no_startup_id STR
1769 struct Autostart *new = smalloc(sizeof(struct Autostart));
1771 new->no_startup_id = $2;
1772 TAILQ_INSERT_TAIL(&autostarts_always, new, autostarts_always);
1776 optional_border_width:
1777 /* empty */ { $$ = 2; } // 2 pixels is the default value for any type of border
1778 | NUMBER { $$ = $1; }
1781 optional_no_startup_id:
1782 /* empty */ { $$ = false; }
1783 | TOK_NO_STARTUP_ID { $$ = true; }
1789 ELOG("The terminal option is DEPRECATED and has no effect. "
1790 "Please remove it from your configuration file.\n");
1797 config.font = load_font($2, true);
1798 set_font(&config.font);
1799 printf("font %s\n", $2);
1806 TOKSINGLECOLOR colorpixel
1808 uint32_t *dest = $1;
1814 TOKCOLOR colorpixel colorpixel colorpixel
1816 struct Colortriple *dest = $1;
1819 dest->background = $3;
1822 | TOKCOLOR colorpixel colorpixel colorpixel colorpixel
1824 struct Colortriple *dest = $1;
1827 dest->background = $3;
1829 dest->indicator = $5;
1836 $$ = get_colorpixel($1);
1843 /* NULL */ { $$ = 0; }
1845 | binding_modifiers '+' binding_modifier { $$ = $1 | $3; }
1846 | binding_modifiers '+' { $$ = $1; }
1850 MODIFIER { $$ = $1; }
1851 | TOKCONTROL { $$ = BIND_CONTROL; }
1852 | TOKSHIFT { $$ = BIND_SHIFT; }
1855 popup_during_fullscreen:
1856 TOK_POPUP_DURING_FULLSCREEN popup_setting
1858 DLOG("popup_during_fullscreen setting: %d\n", $2);
1859 config.popup_during_fullscreen = $2;
1864 TOK_IGNORE { $$ = PDF_IGNORE; }
1865 | TOK_LEAVE_FULLSCREEN { $$ = PDF_LEAVE_FULLSCREEN; }