3 * vim:ts=4:sw=4:expandtab
7 #define I3__FILE__ "cfgparse.y"
16 bool force_old_config_parser = false;
18 static pid_t configerror_pid = -1;
20 static Match current_match;
21 static Barconfig current_bar;
22 /* The pattern which was specified by the user, for example -misc-fixed-*. We
23 * store this in a separate variable because in the i3 config struct we just
24 * store the i3Font. */
25 static char *font_pattern;
26 /* The path to the temporary script files used by i3-nagbar. We need to keep
27 * them around to delete the files in the i3-nagbar SIGCHLD handler. */
28 static char *edit_script_path, *pager_script_path;
30 typedef struct yy_buffer_state *YY_BUFFER_STATE;
31 extern int yylex(struct context *context);
32 extern int yyparse(void);
33 extern int yylex_destroy(void);
35 YY_BUFFER_STATE yy_scan_string(const char *);
37 static struct bindings_head *current_bindings;
38 static struct context *context;
40 /* We don’t need yydebug for now, as we got decent error messages using
41 * yyerror(). Should you ever want to extend the parser, it might be handy
42 * to just comment it in again, so it stays here. */
45 void yyerror(const char *error_message) {
46 context->has_errors = true;
49 ELOG("CONFIG: %s\n", error_message);
50 ELOG("CONFIG: in file \"%s\", line %d:\n",
51 context->filename, context->line_number);
52 ELOG("CONFIG: %s\n", context->line_copy);
53 char buffer[context->last_column+1];
54 buffer[context->last_column] = '\0';
55 for (int c = 1; c <= context->last_column; c++)
56 buffer[c-1] = (c >= context->first_column ? '^' : ' ');
57 ELOG("CONFIG: %s\n", buffer);
66 * Goes through each line of buf (separated by \n) and checks for statements /
67 * commands which only occur in i3 v4 configuration files. If it finds any, it
68 * returns version 4, otherwise it returns version 3.
71 static int detect_version(char *buf) {
74 while (*walk != '\0') {
80 /* check for some v4-only statements */
81 if (strncasecmp(line, "bindcode", strlen("bindcode")) == 0 ||
82 strncasecmp(line, "force_focus_wrapping", strlen("force_focus_wrapping")) == 0 ||
83 strncasecmp(line, "# i3 config file (v4)", strlen("# i3 config file (v4)")) == 0 ||
84 strncasecmp(line, "workspace_layout", strlen("workspace_layout")) == 0) {
85 printf("deciding for version 4 due to this line: %.*s\n", (int)(walk-line), line);
89 /* if this is a bind statement, we can check the command */
90 if (strncasecmp(line, "bind", strlen("bind")) == 0) {
91 char *bind = strchr(line, ' ');
94 while ((*bind == ' ' || *bind == '\t') && *bind != '\0')
98 if ((bind = strchr(bind, ' ')) == NULL)
100 while ((*bind == ' ' || *bind == '\t') && *bind != '\0')
104 if (strncasecmp(bind, "layout", strlen("layout")) == 0 ||
105 strncasecmp(bind, "floating", strlen("floating")) == 0 ||
106 strncasecmp(bind, "workspace", strlen("workspace")) == 0 ||
107 strncasecmp(bind, "focus left", strlen("focus left")) == 0 ||
108 strncasecmp(bind, "focus right", strlen("focus right")) == 0 ||
109 strncasecmp(bind, "focus up", strlen("focus up")) == 0 ||
110 strncasecmp(bind, "focus down", strlen("focus down")) == 0 ||
111 strncasecmp(bind, "border normal", strlen("border normal")) == 0 ||
112 strncasecmp(bind, "border 1pixel", strlen("border 1pixel")) == 0 ||
113 strncasecmp(bind, "border pixel", strlen("border pixel")) == 0 ||
114 strncasecmp(bind, "border borderless", strlen("border borderless")) == 0 ||
115 strncasecmp(bind, "--no-startup-id", strlen("--no-startup-id")) == 0 ||
116 strncasecmp(bind, "bar", strlen("bar")) == 0) {
117 printf("deciding for version 4 due to this line: %.*s\n", (int)(walk-line), line);
123 /* advance to the next line */
132 * Calls i3-migrate-config-to-v4 to migrate a configuration file (input
135 * Returns the converted config file or NULL if there was an error (for
136 * example the script could not be found in $PATH or the i3 executable’s
140 static char *migrate_config(char *input, off_t size) {
144 if (pipe(writepipe) != 0 ||
145 pipe(readpipe) != 0) {
146 warn("migrate_config: Could not create pipes");
152 warn("Could not fork()");
158 /* close writing end of writepipe, connect reading side to stdin */
160 dup2(writepipe[0], 0);
162 /* close reading end of readpipe, connect writing side to stdout */
164 dup2(readpipe[1], 1);
166 static char *argv[] = {
167 NULL, /* will be replaced by the executable path */
170 exec_i3_utility("i3-migrate-config-to-v4", argv);
175 /* close reading end of the writepipe (connected to the script’s stdin) */
178 /* write the whole config file to the pipe, the script will read everything
182 while (written < size) {
183 if ((ret = write(writepipe[1], input + written, size - written)) < 0) {
184 warn("Could not write to pipe");
191 /* close writing end of the readpipe (connected to the script’s stdout) */
194 /* read the script’s output */
195 int conv_size = 65535;
196 char *converted = malloc(conv_size);
199 if (read_bytes == conv_size) {
201 converted = realloc(converted, conv_size);
203 ret = read(readpipe[0], converted + read_bytes, conv_size - read_bytes);
205 warn("Cannot read from pipe");
212 /* get the returncode */
215 if (!WIFEXITED(status)) {
216 fprintf(stderr, "Child did not terminate normally, using old config file (will lead to broken behaviour)\n");
220 int returncode = WEXITSTATUS(status);
221 if (returncode != 0) {
222 fprintf(stderr, "Migration process exit code was != 0\n");
223 if (returncode == 2) {
224 fprintf(stderr, "could not start the migration script\n");
225 /* TODO: script was not found. tell the user to fix his system or create a v4 config */
226 } else if (returncode == 1) {
227 fprintf(stderr, "This already was a v4 config. Please add the following line to your config file:\n");
228 fprintf(stderr, "# i3 config file (v4)\n");
229 /* TODO: nag the user with a message to include a hint for i3 in his config file */
238 * Handler which will be called when we get a SIGCHLD for the nagbar, meaning
239 * it exited (or could not be started, depending on the exit code).
242 static void nagbar_exited(EV_P_ ev_child *watcher, int revents) {
243 ev_child_stop(EV_A_ watcher);
245 if (unlink(edit_script_path) != 0)
246 warn("Could not delete temporary i3-nagbar script %s", edit_script_path);
247 if (unlink(pager_script_path) != 0)
248 warn("Could not delete temporary i3-nagbar script %s", pager_script_path);
250 if (!WIFEXITED(watcher->rstatus)) {
251 fprintf(stderr, "ERROR: i3-nagbar did not exit normally.\n");
255 int exitcode = WEXITSTATUS(watcher->rstatus);
256 printf("i3-nagbar process exited with status %d\n", exitcode);
258 fprintf(stderr, "ERROR: i3-nagbar could not be found. Is it correctly installed on your system?\n");
261 configerror_pid = -1;
264 /* We need ev >= 4 for the following code. Since it is not *that* important (it
265 * only makes sure that there are no i3-nagbar instances left behind) we still
266 * support old systems with libev 3. */
267 #if EV_VERSION_MAJOR >= 4
269 * Cleanup handler. Will be called when i3 exits. Kills i3-nagbar with signal
270 * SIGKILL (9) to make sure there are no left-over i3-nagbar processes.
273 static void nagbar_cleanup(EV_P_ ev_cleanup *watcher, int revent) {
274 if (configerror_pid != -1) {
275 LOG("Sending SIGKILL (9) to i3-nagbar with PID %d\n", configerror_pid);
276 kill(configerror_pid, SIGKILL);
282 * Writes the given command as a shell script to path.
283 * Returns true unless something went wrong.
286 static bool write_nagbar_script(const char *path, const char *command) {
287 int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IXUSR);
289 warn("Could not create temporary script to store the nagbar command");
292 write(fd, "#!/bin/sh\n", strlen("#!/bin/sh\n"));
293 write(fd, command, strlen(command));
299 * Starts an i3-nagbar process which alerts the user that his configuration
300 * file contains one or more errors. Also offers two buttons: One to launch an
301 * $EDITOR on the config file and another one to launch a $PAGER on the error
305 static void start_configerror_nagbar(const char *config_path) {
306 if (only_check_config)
309 fprintf(stderr, "Starting i3-nagbar due to configuration errors\n");
311 /* We need to create a custom script containing our actual command
312 * since not every terminal emulator which is contained in
313 * i3-sensible-terminal supports -e with multiple arguments (and not
314 * all of them support -e with one quoted argument either).
316 * NB: The paths need to be unique, that is, don’t assume users close
317 * their nagbars at any point in time (and they still need to work).
319 edit_script_path = get_process_filename("nagbar-cfgerror-edit");
320 pager_script_path = get_process_filename("nagbar-cfgerror-pager");
322 configerror_pid = fork();
323 if (configerror_pid == -1) {
324 warn("Could not fork()");
329 if (configerror_pid == 0) {
330 char *edit_command, *pager_command;
331 sasprintf(&edit_command, "i3-sensible-editor \"%s\" && i3-msg reload\n", config_path);
332 sasprintf(&pager_command, "i3-sensible-pager \"%s\"\n", errorfilename);
333 if (!write_nagbar_script(edit_script_path, edit_command) ||
334 !write_nagbar_script(pager_script_path, pager_command))
339 sasprintf(&editaction, "i3-sensible-terminal -e \"%s\"", edit_script_path);
340 sasprintf(&pageraction, "i3-sensible-terminal -e \"%s\"", pager_script_path);
342 NULL, /* will be replaced by the executable path */
344 (context->has_errors ? "error" : "warning"),
346 (context->has_errors ?
347 "You have an error in your i3 config file!" :
348 "Your config is outdated. Please fix the warnings to make sure everything works."),
352 (errorfilename ? "-b" : NULL),
353 (context->has_errors ? "show errors" : "show warnings"),
357 exec_i3_utility("i3-nagbar", argv);
361 /* install a child watcher */
362 ev_child *child = smalloc(sizeof(ev_child));
363 ev_child_init(child, &nagbar_exited, configerror_pid, 0);
364 ev_child_start(main_loop, child);
366 /* We need ev >= 4 for the following code. Since it is not *that* important (it
367 * only makes sure that there are no i3-nagbar instances left behind) we still
368 * support old systems with libev 3. */
369 #if EV_VERSION_MAJOR >= 4
370 /* install a cleanup watcher (will be called when i3 exits and i3-nagbar is
372 ev_cleanup *cleanup = smalloc(sizeof(ev_cleanup));
373 ev_cleanup_init(cleanup, nagbar_cleanup);
374 ev_cleanup_start(main_loop, cleanup);
379 * Kills the configerror i3-nagbar process, if any.
381 * Called when reloading/restarting.
383 * If wait_for_it is set (restarting), this function will waitpid(), otherwise,
384 * ev is assumed to handle it (reloading).
387 void kill_configerror_nagbar(bool wait_for_it) {
388 if (configerror_pid == -1)
391 if (kill(configerror_pid, SIGTERM) == -1)
392 warn("kill(configerror_nagbar) failed");
397 /* When restarting, we don’t enter the ev main loop anymore and after the
398 * exec(), our old pid is no longer watched. So, ev won’t handle SIGCHLD
399 * for us and we would end up with a <defunct> process. Therefore we
401 waitpid(configerror_pid, NULL, 0);
405 * Checks for duplicate key bindings (the same keycode or keysym is configured
406 * more than once). If a duplicate binding is found, a message is printed to
407 * stderr and the has_errors variable is set to true, which will start
411 static void check_for_duplicate_bindings(struct context *context) {
412 Binding *bind, *current;
413 TAILQ_FOREACH(current, bindings, bindings) {
414 TAILQ_FOREACH(bind, bindings, bindings) {
415 /* Abort when we reach the current keybinding, only check the
420 /* Check if one is using keysym while the other is using bindsym.
422 /* XXX: It should be checked at a later place (when translating the
423 * keysym to keycodes) if there are any duplicates */
424 if ((bind->symbol == NULL && current->symbol != NULL) ||
425 (bind->symbol != NULL && current->symbol == NULL))
428 /* If bind is NULL, current has to be NULL, too (see above).
429 * If the keycodes differ, it can't be a duplicate. */
430 if (bind->symbol != NULL &&
431 strcasecmp(bind->symbol, current->symbol) != 0)
434 /* Check if the keycodes or modifiers are different. If so, they
435 * can't be duplicate */
436 if (bind->keycode != current->keycode ||
437 bind->mods != current->mods ||
438 bind->release != current->release)
441 context->has_errors = true;
442 if (current->keycode != 0) {
443 ELOG("Duplicate keybinding in config file:\n modmask %d with keycode %d, command \"%s\"\n",
444 current->mods, current->keycode, current->command);
446 ELOG("Duplicate keybinding in config file:\n modmask %d with keysym %s, command \"%s\"\n",
447 current->mods, current->symbol, current->command);
453 static void migrate_i3bar_exec(struct Autostart *exec) {
454 ELOG("**********************************************************************\n");
455 ELOG("IGNORING exec command: %s\n", exec->command);
456 ELOG("It contains \"i3bar\". Since i3 v4.1, i3bar will be automatically started\n");
457 ELOG("for each 'bar' configuration block in your i3 config. Please remove the exec\n");
458 ELOG("line and add the following to your i3 config:\n");
461 ELOG(" status_command i3status\n");
463 ELOG("**********************************************************************\n");
465 /* Generate a dummy bar configuration */
466 Barconfig *bar_config = scalloc(sizeof(Barconfig));
467 /* The hard-coded ID is not a problem. It does not conflict with the
468 * auto-generated bar IDs and having multiple hard-coded IDs is irrelevant
469 * – they all just contain status_command = i3status */
470 bar_config->id = sstrdup("migrate-bar");
471 bar_config->status_command = sstrdup("i3status");
472 TAILQ_INSERT_TAIL(&barconfigs, bar_config, configs);
474 /* Trigger an i3-nagbar */
475 context->has_warnings = true;
478 void parse_file(const char *f) {
479 SLIST_HEAD(variables_head, Variable) variables = SLIST_HEAD_INITIALIZER(&variables);
480 int fd, ret, read_bytes = 0;
484 char buffer[1026], key[512], value[512];
486 if ((fd = open(f, O_RDONLY)) == -1)
487 die("Could not open configuration file: %s\n", strerror(errno));
489 if (fstat(fd, &stbuf) == -1)
490 die("Could not fstat file: %s\n", strerror(errno));
492 buf = scalloc((stbuf.st_size + 1) * sizeof(char));
493 while (read_bytes < stbuf.st_size) {
494 if ((ret = read(fd, buf + read_bytes, (stbuf.st_size - read_bytes))) < 0)
495 die("Could not read(): %s\n", strerror(errno));
499 if (lseek(fd, 0, SEEK_SET) == (off_t)-1)
500 die("Could not lseek: %s\n", strerror(errno));
502 if ((fstr = fdopen(fd, "r")) == NULL)
503 die("Could not fdopen: %s\n", strerror(errno));
505 while (!feof(fstr)) {
506 if (fgets(buffer, 1024, fstr) == NULL) {
509 die("Could not read configuration file\n");
512 /* sscanf implicitly strips whitespace. Also, we skip comments and empty lines. */
513 if (sscanf(buffer, "%s %[^\n]", key, value) < 1 ||
514 key[0] == '#' || strlen(key) < 3)
517 if (strcasecmp(key, "set") == 0) {
518 if (value[0] != '$') {
519 ELOG("Malformed variable assignment, name has to start with $\n");
523 /* get key/value for this variable */
524 char *v_key = value, *v_value;
525 if (strstr(value, " ") == NULL && strstr(value, "\t") == NULL) {
526 ELOG("Malformed variable assignment, need a value\n");
530 if (!(v_value = strstr(value, " ")))
531 v_value = strstr(value, "\t");
534 while (*v_value == '\t' || *v_value == ' ')
537 struct Variable *new = scalloc(sizeof(struct Variable));
538 new->key = sstrdup(v_key);
539 new->value = sstrdup(v_value);
540 SLIST_INSERT_HEAD(&variables, new, variables);
541 DLOG("Got new variable %s = %s\n", v_key, v_value);
547 /* For every custom variable, see how often it occurs in the file and
548 * how much extra bytes it requires when replaced. */
549 struct Variable *current, *nearest;
551 /* We need to copy the buffer because we need to invalidate the
552 * variables (otherwise we will count them twice, which is bad when
553 * 'extra' is negative) */
554 char *bufcopy = sstrdup(buf);
555 SLIST_FOREACH(current, &variables, variables) {
556 int extra = (strlen(current->value) - strlen(current->key));
559 next < (bufcopy + stbuf.st_size) &&
560 (next = strcasestr(next, current->key)) != NULL;
561 next += strlen(current->key)) {
563 extra_bytes += extra;
568 /* Then, allocate a new buffer and copy the file over to the new one,
569 * but replace occurences of our variables */
570 char *walk = buf, *destwalk;
571 char *new = smalloc((stbuf.st_size + extra_bytes + 1) * sizeof(char));
573 while (walk < (buf + stbuf.st_size)) {
574 /* Find the next variable */
575 SLIST_FOREACH(current, &variables, variables)
576 current->next_match = strcasestr(walk, current->key);
578 int distance = stbuf.st_size;
579 SLIST_FOREACH(current, &variables, variables) {
580 if (current->next_match == NULL)
582 if ((current->next_match - walk) < distance) {
583 distance = (current->next_match - walk);
587 if (nearest == NULL) {
588 /* If there are no more variables, we just copy the rest */
589 strncpy(destwalk, walk, (buf + stbuf.st_size) - walk);
590 destwalk += (buf + stbuf.st_size) - walk;
594 /* Copy until the next variable, then copy its value */
595 strncpy(destwalk, walk, distance);
596 strncpy(destwalk + distance, nearest->value, strlen(nearest->value));
597 walk += distance + strlen(nearest->key);
598 destwalk += distance + strlen(nearest->value);
602 /* analyze the string to find out whether this is an old config file (3.x)
603 * or a new config file (4.x). If it’s old, we run the converter script. */
604 int version = detect_version(buf);
606 /* We need to convert this v3 configuration */
607 char *converted = migrate_config(new, stbuf.st_size);
608 if (converted != NULL) {
610 ELOG("****************************************************************\n");
611 ELOG("NOTE: Automatically converted configuration file from v3 to v4.\n");
613 ELOG("Please convert your config file to v4. You can use this command:\n");
614 ELOG(" mv %s %s.O\n", f, f);
615 ELOG(" i3-migrate-config-to-v4 %s.O > %s\n", f, f);
616 ELOG("****************************************************************\n");
622 printf("**********************************************************************\n");
623 printf("ERROR: Could not convert config file. Maybe i3-migrate-config-to-v4\n");
624 printf("was not correctly installed on your system?\n");
625 printf("**********************************************************************\n");
631 context = scalloc(sizeof(struct context));
632 context->filename = f;
634 if (force_old_config_parser) {
635 /* now lex/parse it */
637 if (yyparse() != 0) {
638 fprintf(stderr, "Could not parse configfile\n");
642 struct ConfigResult *config_output = parse_config(new, context);
643 yajl_gen_free(config_output->json_gen);
646 check_for_duplicate_bindings(context);
648 /* XXX: The following code will be removed in i3 v4.3 (three releases from
649 * now, as of 2011-10-22) */
650 /* Check for any exec or exec_always lines starting i3bar. We remove these
651 * and add a bar block instead. Additionally, a i3-nagbar warning (not an
652 * error) will be displayed so that users update their config file. */
653 struct Autostart *exec, *next;
654 for (exec = TAILQ_FIRST(&autostarts); exec; ) {
655 next = TAILQ_NEXT(exec, autostarts);
656 if (strstr(exec->command, "i3bar") != NULL) {
657 migrate_i3bar_exec(exec);
658 TAILQ_REMOVE(&autostarts, exec, autostarts);
663 for (exec = TAILQ_FIRST(&autostarts_always); exec; ) {
664 next = TAILQ_NEXT(exec, autostarts_always);
665 if (strstr(exec->command, "i3bar") != NULL) {
666 migrate_i3bar_exec(exec);
667 TAILQ_REMOVE(&autostarts_always, exec, autostarts_always);
672 if (context->has_errors || context->has_warnings) {
673 ELOG("FYI: You are using i3 version " I3_VERSION "\n");
675 ELOG("Please convert your configfile first, then fix any remaining errors (see above).\n");
676 start_configerror_nagbar(f);
679 if (force_old_config_parser)
681 FREE(context->line_copy);
687 while (!SLIST_EMPTY(&variables)) {
688 current = SLIST_FIRST(&variables);
690 FREE(current->value);
691 SLIST_REMOVE_HEAD(&variables, variables);
699 %lex-param { struct context *context }
704 uint32_t *single_color;
705 struct Colortriple *color;
707 struct Binding *binding;
710 %token <number> NUMBER "<number>"
711 %token <string> WORD "<word>"
712 %token <string> STR "<string>"
713 %token <string> STR_NG "<string (non-greedy)>"
714 %token <string> HEXCOLOR "#<hex>"
715 %token <string> OUTPUT "<RandR output>"
718 %token TOKCOMMENT "<comment>"
719 %token TOKFONT "font"
720 %token TOKBINDSYM "bindsym"
721 %token <number> MODIFIER "<modifier>"
722 %token TOKCONTROL "control"
723 %token TOKSHIFT "shift"
724 %token TOKFLOATING_MODIFIER "floating_modifier"
725 %token TOKFLOATING_MAXIMUM_SIZE "floating_maximum_size"
726 %token TOKFLOATING_MINIMUM_SIZE "floating_minimum_size"
727 %token <string> QUOTEDSTRING "<quoted string>"
728 %token TOKWORKSPACE "workspace"
729 %token TOKOUTPUT "output"
730 %token TOKASSIGN "assign"
732 %token TOKIPCSOCKET "ipc_socket"
733 %token TOKRESTARTSTATE "restart_state"
734 %token TOKEXEC "exec"
735 %token TOKEXEC_ALWAYS "exec_always"
736 %token <single_color> TOKSINGLECOLOR
737 %token <color> TOKCOLOR
739 %token TOKMODE "mode"
740 %token TOK_TIME_MS "ms"
742 %token TOK_ORIENTATION "default_orientation"
743 %token TOK_HORIZ "horizontal"
744 %token TOK_VERT "vertical"
745 %token TOK_AUTO "auto"
746 %token TOK_WORKSPACE_LAYOUT "workspace_layout"
747 %token TOKNEWWINDOW "new_window"
748 %token TOKNEWFLOAT "new_float"
749 %token TOK_NORMAL "normal"
750 %token TOK_NONE "none"
751 %token TOK_PIXEL "pixel"
752 %token TOK_1PIXEL "1pixel"
753 %token TOK_HIDE_EDGE_BORDERS "hide_edge_borders"
754 %token TOK_BOTH "both"
755 %token TOKFOCUSFOLLOWSMOUSE "focus_follows_mouse"
756 %token TOK_FORCE_FOCUS_WRAPPING "force_focus_wrapping"
757 %token TOK_FORCE_XINERAMA "force_xinerama"
758 %token TOK_FAKE_OUTPUTS "fake_outputs"
759 %token TOK_WORKSPACE_AUTO_BAF "workspace_auto_back_and_forth"
760 %token TOK_WORKSPACE_URGENCY_TIMER "force_display_urgency_hint"
761 %token TOKWORKSPACEBAR "workspace_bar"
762 %token TOK_DEFAULT "default"
763 %token TOK_STACKING "stacking"
764 %token TOK_TABBED "tabbed"
765 %token <number> TOKSTACKLIMIT "stack-limit"
766 %token TOK_POPUP_DURING_FULLSCREEN "popup_during_fullscreen"
767 %token TOK_IGNORE "ignore"
768 %token TOK_LEAVE_FULLSCREEN "leave_fullscreen"
769 %token TOK_FOR_WINDOW "for_window"
771 %token TOK_BAR_OUTPUT "output (bar)"
772 %token TOK_BAR_TRAY_OUTPUT "tray_output"
773 %token TOK_BAR_SOCKET_PATH "socket_path"
774 %token TOK_BAR_MODE "mode (bar)"
775 %token TOK_BAR_HIDE "hide"
776 %token TOK_BAR_DOCK "dock"
777 %token TOK_BAR_MODIFIER "modifier (bar)"
778 %token TOK_BAR_CONTROL "shift (bar)"
779 %token TOK_BAR_SHIFT "control (bar)"
780 %token TOK_BAR_MOD1 "Mod1"
781 %token TOK_BAR_MOD2 "Mod2"
782 %token TOK_BAR_MOD3 "Mod3"
783 %token TOK_BAR_MOD4 "Mod4"
784 %token TOK_BAR_MOD5 "Mod5"
785 %token TOK_BAR_POSITION "position"
786 %token TOK_BAR_BOTTOM "bottom"
787 %token TOK_BAR_TOP "top"
788 %token TOK_BAR_STATUS_COMMAND "status_command"
789 %token TOK_BAR_I3BAR_COMMAND "i3bar_command"
790 %token TOK_BAR_FONT "font (bar)"
791 %token TOK_BAR_WORKSPACE_BUTTONS "workspace_buttons"
792 %token TOK_BAR_VERBOSE "verbose"
793 %token TOK_BAR_COLORS "colors"
794 %token TOK_BAR_COLOR_BACKGROUND "background"
795 %token TOK_BAR_COLOR_STATUSLINE "statusline"
796 %token TOK_BAR_COLOR_FOCUSED_WORKSPACE "focused_workspace"
797 %token TOK_BAR_COLOR_ACTIVE_WORKSPACE "active_workspace"
798 %token TOK_BAR_COLOR_INACTIVE_WORKSPACE "inactive_workspace"
799 %token TOK_BAR_COLOR_URGENT_WORKSPACE "urgent_workspace"
800 %token TOK_NO_STARTUP_ID "--no-startup-id"
801 %token TOK_RELEASE "--release"
803 %token TOK_MARK "mark"
804 %token TOK_CLASS "class"
805 %token TOK_INSTANCE "instance"
806 %token TOK_WINDOW_ROLE "window_role"
808 %token TOK_CON_ID "con_id"
809 %token TOK_TITLE "title"
810 %token TOK_URGENT "urgent"
812 %type <binding> binding
813 %type <binding> bindcode
814 %type <binding> bindsym
815 %type <number> binding_modifiers
816 %type <number> binding_modifier
817 %type <number> direction
818 %type <number> layout_mode
819 %type <number> border_style
820 %type <number> new_window
821 %type <number> hide_edge_borders
822 %type <number> edge_hiding_mode
823 %type <number> new_float
824 %type <number> colorpixel
826 %type <number> popup_setting
827 %type <number> bar_position_position
828 %type <number> bar_mode_mode
829 %type <number> bar_modifier_modifier
830 %type <number> optional_no_startup_id
831 %type <number> optional_border_width
832 %type <number> optional_release
833 %type <string> command
834 %type <string> word_or_number
835 %type <string> duration
836 %type <string> qstring_or_number
837 %type <string> optional_workspace_name
838 %type <string> workspace_name
839 %type <string> window_class
853 | floating_maximum_size
854 | floating_minimum_size
861 | focus_follows_mouse
862 | force_focus_wrapping
865 | force_display_urgency_hint
866 | workspace_back_and_forth
879 | popup_during_fullscreen
893 TAILQ_INSERT_TAIL(bindings, $1, bindings);
898 TOKBINDCODE bindcode { $$ = $2; }
899 | TOKBINDSYM bindsym { $$ = $2; }
903 optional_release binding_modifiers NUMBER command
905 DLOG("bindcode: release = %d, mod = %d, key = %d, command = %s\n", $1, $2, $3, $4);
906 Binding *new = scalloc(sizeof(Binding));
918 optional_release binding_modifiers word_or_number command
920 DLOG("bindsym: release = %d, mod = %d, key = %s, command = %s\n", $1, $2, $3, $4);
921 Binding *new = scalloc(sizeof(Binding));
933 /* empty */ { $$ = B_UPON_KEYPRESS; }
934 | TOK_RELEASE { $$ = B_UPON_KEYRELEASE; }
938 TOK_FOR_WINDOW match command
940 if (match_is_empty(¤t_match)) {
941 ELOG("Match is empty, ignoring this for_window statement\n");
944 printf("\t should execute command %s for the criteria mentioned above\n", $3);
945 Assignment *assignment = scalloc(sizeof(Assignment));
946 assignment->type = A_COMMAND;
947 assignment->match = current_match;
948 assignment->dest.command = $3;
949 TAILQ_INSERT_TAIL(&assignments, assignment, assignments);
954 | matchstart criteria matchend
956 printf("match parsed\n");
964 match_init(¤t_match);
971 printf("match specification finished\n");
983 printf("criteria: class = %s\n", $3);
984 current_match.class = regex_new($3);
987 | TOK_INSTANCE '=' STR
989 printf("criteria: instance = %s\n", $3);
990 current_match.instance = regex_new($3);
993 | TOK_WINDOW_ROLE '=' STR
995 printf("criteria: window_role = %s\n", $3);
996 current_match.role = regex_new($3);
1001 printf("criteria: 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 con id \"%s\"\n", $3);
1010 current_match.con_id = (Con*)parsed;
1011 printf("id as int = %p\n", current_match.con_id);
1016 printf("criteria: window id = %s\n", $3);
1018 long parsed = strtol($3, &end, 10);
1019 if (parsed == LONG_MIN ||
1020 parsed == LONG_MAX ||
1022 (end && *end != '\0')) {
1023 ELOG("Could not parse window id \"%s\"\n", $3);
1025 current_match.id = parsed;
1026 printf("window id as int = %d\n", current_match.id);
1031 printf("criteria: mark = %s\n", $3);
1032 current_match.mark = regex_new($3);
1037 printf("criteria: title = %s\n", $3);
1038 current_match.title = regex_new($3);
1041 | TOK_URGENT '=' STR
1043 printf("criteria: urgent = %s\n", $3);
1044 if (strcasecmp($3, "latest") == 0 ||
1045 strcasecmp($3, "newest") == 0 ||
1046 strcasecmp($3, "recent") == 0 ||
1047 strcasecmp($3, "last") == 0) {
1048 current_match.urgent = U_LATEST;
1049 } else if (strcasecmp($3, "oldest") == 0 ||
1050 strcasecmp($3, "first") == 0) {
1051 current_match.urgent = U_OLDEST;
1059 | NUMBER { sasprintf(&$$, "%d", $1); }
1066 sasprintf(&$$, "%d", $1);
1071 NUMBER { sasprintf(&$$, "%d", $1); }
1072 | NUMBER TOK_TIME_MS { sasprintf(&$$, "%d", $1); }
1076 TOKMODE QUOTEDSTRING '{' modelines '}'
1078 if (strcasecmp($2, "default") == 0) {
1079 printf("You cannot use the name \"default\" for your mode\n");
1082 printf("\t now in mode %s\n", $2);
1083 printf("\t current bindings = %p\n", current_bindings);
1085 TAILQ_FOREACH(binding, current_bindings, bindings) {
1086 printf("got binding on mods %d, keycode %d, symbol %s, command %s\n",
1087 binding->mods, binding->keycode, binding->symbol, binding->command);
1090 struct Mode *mode = scalloc(sizeof(struct Mode));
1092 mode->bindings = current_bindings;
1093 current_bindings = NULL;
1094 SLIST_INSERT_HEAD(&modes, mode, modes);
1101 | modelines modeline
1108 if (current_bindings == NULL) {
1109 current_bindings = scalloc(sizeof(struct bindings_head));
1110 TAILQ_INIT(current_bindings);
1113 TAILQ_INSERT_TAIL(current_bindings, $1, bindings);
1118 TOK_BAR '{' barlines '}'
1120 printf("\t new bar configuration finished, saving.\n");
1121 /* Generate a unique ID for this bar */
1122 current_bar.id = sstrdup("bar-XXXXXX");
1123 /* This works similar to mktemp in that it replaces the last six X with
1124 * random letters, but without the restriction that the given buffer
1125 * has to contain a valid path name. */
1126 char *x = current_bar.id + strlen("bar-");
1127 while (*x != '\0') {
1128 *(x++) = (rand() % 26) + 'a';
1131 /* If no font was explicitly set, we use the i3 font as default */
1132 if (!current_bar.font && font_pattern)
1133 current_bar.font = sstrdup(font_pattern);
1135 /* Copy the current (static) structure into a dynamically allocated
1136 * one, then cleanup our static one. */
1137 Barconfig *bar_config = scalloc(sizeof(Barconfig));
1138 memcpy(bar_config, ¤t_bar, sizeof(Barconfig));
1139 TAILQ_INSERT_TAIL(&barconfigs, bar_config, configs);
1141 memset(¤t_bar, '\0', sizeof(Barconfig));
1152 | bar_status_command
1160 | bar_workspace_buttons
1164 | bar_color_background
1165 | bar_color_statusline
1166 | bar_color_focused_workspace
1167 | bar_color_active_workspace
1168 | bar_color_inactive_workspace
1169 | bar_color_urgent_workspace
1173 TOK_BAR_STATUS_COMMAND STR
1175 DLOG("should add status command %s\n", $2);
1176 FREE(current_bar.status_command);
1177 current_bar.status_command = $2;
1182 TOK_BAR_I3BAR_COMMAND STR
1184 DLOG("should add i3bar_command %s\n", $2);
1185 FREE(current_bar.i3bar_command);
1186 current_bar.i3bar_command = $2;
1193 DLOG("bar output %s\n", $2);
1194 int new_outputs = current_bar.num_outputs + 1;
1195 current_bar.outputs = srealloc(current_bar.outputs, sizeof(char*) * new_outputs);
1196 current_bar.outputs[current_bar.num_outputs] = $2;
1197 current_bar.num_outputs = new_outputs;
1202 TOK_BAR_TRAY_OUTPUT STR
1204 DLOG("tray %s\n", $2);
1205 FREE(current_bar.tray_output);
1206 current_bar.tray_output = $2;
1211 TOK_BAR_POSITION bar_position_position
1213 DLOG("position %d\n", $2);
1214 current_bar.position = $2;
1218 bar_position_position:
1219 TOK_BAR_TOP { $$ = P_TOP; }
1220 | TOK_BAR_BOTTOM { $$ = P_BOTTOM; }
1224 TOK_BAR_MODE bar_mode_mode
1226 DLOG("mode %d\n", $2);
1227 current_bar.mode = $2;
1232 TOK_BAR_HIDE { $$ = M_HIDE; }
1233 | TOK_BAR_DOCK { $$ = M_DOCK; }
1237 TOK_BAR_MODIFIER bar_modifier_modifier
1239 DLOG("modifier %d\n", $2);
1240 current_bar.modifier = $2;
1243 bar_modifier_modifier:
1244 TOK_BAR_CONTROL { $$ = M_CONTROL; }
1245 | TOK_BAR_SHIFT { $$ = M_SHIFT; }
1246 | TOK_BAR_MOD1 { $$ = M_MOD1; }
1247 | TOK_BAR_MOD2 { $$ = M_MOD2; }
1248 | TOK_BAR_MOD3 { $$ = M_MOD3; }
1249 | TOK_BAR_MOD4 { $$ = M_MOD4; }
1250 | TOK_BAR_MOD5 { $$ = M_MOD5; }
1256 DLOG("font %s\n", $2);
1257 FREE(current_bar.font);
1258 current_bar.font = $2;
1262 bar_workspace_buttons:
1263 TOK_BAR_WORKSPACE_BUTTONS bool
1265 DLOG("workspace_buttons = %d\n", $2);
1266 /* We store this inverted to make the default setting right when
1267 * initializing the struct with zero. */
1268 current_bar.hide_workspace_buttons = !($2);
1273 TOK_BAR_VERBOSE bool
1275 DLOG("verbose = %d\n", $2);
1276 current_bar.verbose = $2;
1281 TOK_BAR_SOCKET_PATH STR
1283 DLOG("socket_path = %s\n", $2);
1284 FREE(current_bar.socket_path);
1285 current_bar.socket_path = $2;
1290 TOK_BAR_COLORS '{' barlines '}'
1292 /* At the moment, the TOK_BAR_COLORS token is only to make the config
1293 * friendlier for humans. We might change this in the future if it gets
1298 bar_color_background:
1299 TOK_BAR_COLOR_BACKGROUND HEXCOLOR
1301 DLOG("background = %s\n", $2);
1302 current_bar.colors.background = $2;
1306 bar_color_statusline:
1307 TOK_BAR_COLOR_STATUSLINE HEXCOLOR
1309 DLOG("statusline = %s\n", $2);
1310 current_bar.colors.statusline = $2;
1314 bar_color_focused_workspace:
1315 TOK_BAR_COLOR_FOCUSED_WORKSPACE HEXCOLOR HEXCOLOR
1317 /* Old syntax: text / background */
1318 DLOG("focused_ws = %s, %s (old)\n", $2, $3);
1319 current_bar.colors.focused_workspace_bg = $3;
1320 current_bar.colors.focused_workspace_text = $2;
1322 | TOK_BAR_COLOR_FOCUSED_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR
1324 /* New syntax: border / background / text */
1325 DLOG("focused_ws = %s, %s and %s\n", $2, $3, $4);
1326 current_bar.colors.focused_workspace_border = $2;
1327 current_bar.colors.focused_workspace_bg = $3;
1328 current_bar.colors.focused_workspace_text = $4;
1332 bar_color_active_workspace:
1333 TOK_BAR_COLOR_ACTIVE_WORKSPACE HEXCOLOR HEXCOLOR
1335 /* Old syntax: text / background */
1336 DLOG("active_ws = %s, %s (old)\n", $2, $3);
1337 current_bar.colors.active_workspace_bg = $3;
1338 current_bar.colors.active_workspace_text = $2;
1340 | TOK_BAR_COLOR_ACTIVE_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR
1342 /* New syntax: border / background / text */
1343 DLOG("active_ws = %s, %s and %s\n", $2, $3, $4);
1344 current_bar.colors.active_workspace_border = $2;
1345 current_bar.colors.active_workspace_bg = $3;
1346 current_bar.colors.active_workspace_text = $4;
1350 bar_color_inactive_workspace:
1351 TOK_BAR_COLOR_INACTIVE_WORKSPACE HEXCOLOR HEXCOLOR
1353 /* Old syntax: text / background */
1354 DLOG("inactive_ws = %s, %s (old)\n", $2, $3);
1355 current_bar.colors.inactive_workspace_bg = $3;
1356 current_bar.colors.inactive_workspace_text = $2;
1358 | TOK_BAR_COLOR_INACTIVE_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR
1360 DLOG("inactive_ws = %s, %s and %s\n", $2, $3, $4);
1361 current_bar.colors.inactive_workspace_border = $2;
1362 current_bar.colors.inactive_workspace_bg = $3;
1363 current_bar.colors.inactive_workspace_text = $4;
1367 bar_color_urgent_workspace:
1368 TOK_BAR_COLOR_URGENT_WORKSPACE HEXCOLOR HEXCOLOR
1370 /* Old syntax: text / background */
1371 DLOG("urgent_ws = %s, %s (old)\n", $2, $3);
1372 current_bar.colors.urgent_workspace_bg = $3;
1373 current_bar.colors.urgent_workspace_text = $2;
1375 | TOK_BAR_COLOR_URGENT_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR
1377 DLOG("urgent_ws = %s, %s and %s\n", $2, $3, $4);
1378 current_bar.colors.urgent_workspace_border = $2;
1379 current_bar.colors.urgent_workspace_bg = $3;
1380 current_bar.colors.urgent_workspace_text = $4;
1384 floating_maximum_size:
1385 TOKFLOATING_MAXIMUM_SIZE NUMBER WORD NUMBER
1387 printf("floating_maximum_width = %d\n", $2);
1388 printf("floating_maximum_height = %d\n", $4);
1389 config.floating_maximum_width = $2;
1390 config.floating_maximum_height = $4;
1394 floating_minimum_size:
1395 TOKFLOATING_MINIMUM_SIZE NUMBER WORD NUMBER
1397 printf("floating_minimum_width = %d\n", $2);
1398 printf("floating_minimum_height = %d\n", $4);
1399 config.floating_minimum_width = $2;
1400 config.floating_minimum_height = $4;
1405 TOKFLOATING_MODIFIER binding_modifiers
1407 DLOG("floating modifier = %d\n", $2);
1408 config.floating_modifier = $2;
1413 TOK_ORIENTATION direction
1415 DLOG("New containers should start with split direction %d\n", $2);
1416 config.default_orientation = $2;
1421 TOK_HORIZ { $$ = HORIZ; }
1422 | TOK_VERT { $$ = VERT; }
1423 | TOK_AUTO { $$ = NO_ORIENTATION; }
1427 TOK_WORKSPACE_LAYOUT layout_mode
1429 DLOG("new containers will be in mode %d\n", $2);
1430 config.default_layout = $2;
1433 /* We also need to change the layout of the already existing
1434 * workspaces here. Workspaces may exist at this point because
1435 * of the other directives which are modifying workspaces
1436 * (setting the preferred screen or name). While the workspace
1437 * objects are already created, they have never been used.
1438 * Thus, the user very likely awaits the default container mode
1439 * to trigger in this case, regardless of where it is inside
1440 * his configuration file. */
1442 TAILQ_FOREACH(ws, workspaces, workspaces) {
1443 if (ws->table == NULL)
1445 switch_layout_mode(global_conn,
1447 config.container_mode);
1451 | TOK_WORKSPACE_LAYOUT TOKSTACKLIMIT TOKSTACKLIMIT NUMBER
1453 DLOG("stack-limit %d with val %d\n", $3, $4);
1454 config.container_stack_limit = $3;
1455 config.container_stack_limit_value = $4;
1458 /* See the comment above */
1460 TAILQ_FOREACH(ws, workspaces, workspaces) {
1461 if (ws->table == NULL)
1463 Container *con = ws->table[0][0];
1464 con->stack_limit = config.container_stack_limit;
1465 con->stack_limit_value = config.container_stack_limit_value;
1472 TOK_DEFAULT { $$ = L_DEFAULT; }
1473 | TOK_STACKING { $$ = L_STACKED; }
1474 | TOK_TABBED { $$ = L_TABBED; }
1478 TOKNEWWINDOW border_style
1480 DLOG("new windows should start with border style %d\n", $2);
1481 config.default_border = $2;
1486 TOKNEWFLOAT border_style
1488 DLOG("new floating windows should start with border style %d\n", $2);
1489 config.default_floating_border = $2;
1494 TOK_NORMAL optional_border_width
1496 /* FIXME: the whole border_style thing actually screws up when new_float is used because it overwrites earlier values :-/ */
1497 config.default_border_width = $2;
1502 config.default_border_width = 1;
1507 config.default_border_width = 0;
1510 | TOK_PIXEL optional_border_width
1512 config.default_border_width = $2;
1524 DLOG("checking word \"%s\"\n", $1);
1525 $$ = (strcasecmp($1, "yes") == 0 ||
1526 strcasecmp($1, "true") == 0 ||
1527 strcasecmp($1, "on") == 0 ||
1528 strcasecmp($1, "enable") == 0 ||
1529 strcasecmp($1, "active") == 0);
1534 TOK_HIDE_EDGE_BORDERS edge_hiding_mode
1536 DLOG("hide edge borders = %d\n", $2);
1537 config.hide_edge_borders = $2;
1542 TOK_NONE { $$ = ADJ_NONE; }
1543 | TOK_VERT { $$ = ADJ_LEFT_SCREEN_EDGE | ADJ_RIGHT_SCREEN_EDGE; }
1544 | TOK_HORIZ { $$ = ADJ_UPPER_SCREEN_EDGE | ADJ_LOWER_SCREEN_EDGE; }
1545 | TOK_BOTH { $$ = ADJ_LEFT_SCREEN_EDGE | ADJ_RIGHT_SCREEN_EDGE | ADJ_UPPER_SCREEN_EDGE | ADJ_LOWER_SCREEN_EDGE; }
1546 | bool { $$ = ($1 ? ADJ_LEFT_SCREEN_EDGE | ADJ_RIGHT_SCREEN_EDGE : ADJ_NONE); }
1549 focus_follows_mouse:
1550 TOKFOCUSFOLLOWSMOUSE bool
1552 DLOG("focus follows mouse = %d\n", $2);
1553 config.disable_focus_follows_mouse = !($2);
1557 force_focus_wrapping:
1558 TOK_FORCE_FOCUS_WRAPPING bool
1560 DLOG("force focus wrapping = %d\n", $2);
1561 config.force_focus_wrapping = $2;
1566 TOK_FORCE_XINERAMA bool
1568 DLOG("force xinerama = %d\n", $2);
1569 config.force_xinerama = $2;
1574 TOK_FAKE_OUTPUTS STR
1576 DLOG("fake outputs = %s\n", $2);
1577 config.fake_outputs = $2;
1581 workspace_back_and_forth:
1582 TOK_WORKSPACE_AUTO_BAF bool
1584 DLOG("automatic workspace back-and-forth = %d\n", $2);
1585 config.workspace_auto_back_and_forth = $2;
1589 force_display_urgency_hint:
1590 TOK_WORKSPACE_URGENCY_TIMER duration
1592 DLOG("workspace urgency_timer = %f\n", atoi($2) / 1000.0);
1593 config.workspace_urgency_timer = atoi($2) / 1000.0;
1598 TOKWORKSPACEBAR bool
1600 DLOG("workspace bar = %d\n", $2);
1601 config.disable_workspace_bar = !($2);
1606 TOKWORKSPACE qstring_or_number TOKOUTPUT OUTPUT optional_workspace_name
1611 ELOG("The old (v3) syntax workspace <number> output <output> <name> is deprecated.\n");
1612 ELOG("Please use the new syntax: workspace \"<workspace>\" output <output>\n");
1613 ELOG("In your case, the following should work:\n");
1614 ELOG(" workspace \"%s\" output %s\n", $5, $4);
1616 context->has_warnings = true;
1619 DLOG("Assigning workspace \"%s\" to output \"%s\"\n", ws_name, $4);
1620 /* Check for earlier assignments of the same workspace so that we
1621 * don’t have assignments of a single workspace to different
1623 struct Workspace_Assignment *assignment;
1624 bool duplicate = false;
1625 TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) {
1626 if (strcasecmp(assignment->name, ws_name) == 0) {
1627 ELOG("You have a duplicate workspace assignment for workspace \"%s\"\n",
1629 assignment->output = $4;
1634 assignment = scalloc(sizeof(struct Workspace_Assignment));
1635 assignment->name = ws_name;
1636 assignment->output = $4;
1637 TAILQ_INSERT_TAIL(&ws_assignments, assignment, ws_assignments);
1640 | TOKWORKSPACE NUMBER workspace_name
1644 DLOG("Invalid workspace assignment, workspace number %d out of range\n", ws_num);
1646 DLOG("workspace name to: %s\n", $3);
1648 if ($<string>3 != NULL) {
1649 workspace_set_name(workspace_get(ws_num - 1), $<string>3);
1657 optional_workspace_name:
1658 /* empty */ { $$ = NULL; }
1659 | workspace_name { $$ = $1; }
1663 QUOTEDSTRING { $$ = $1; }
1669 TOKASSIGN window_class STR
1671 /* This is the old, deprecated form of assignments. It’s provided for
1672 * compatibility in version (4.1, 4.2, 4.3) and will be removed
1673 * afterwards. It triggers an i3-nagbar warning starting from 4.1. */
1674 ELOG("You are using the old assign syntax (without criteria). "
1675 "Please see the User's Guide for the new syntax and fix "
1676 "your config file.\n");
1677 context->has_warnings = true;
1678 printf("assignment of %s to *%s*\n", $2, $3);
1679 char *workspace = $3;
1680 char *criteria = $2;
1682 Assignment *assignment = scalloc(sizeof(Assignment));
1683 Match *match = &(assignment->match);
1686 char *separator = NULL;
1687 if ((separator = strchr(criteria, '/')) != NULL) {
1688 *(separator++) = '\0';
1690 sasprintf(&pattern, "(?i)%s", separator);
1691 match->title = regex_new(pattern);
1693 printf(" title = %s\n", separator);
1695 if (*criteria != '\0') {
1697 sasprintf(&pattern, "(?i)%s", criteria);
1698 match->class = regex_new(pattern);
1700 printf(" class = %s\n", criteria);
1704 /* Compatibility with older versions: If the assignment target starts
1705 * with ~, we create the equivalent of:
1707 * for_window [class="foo"] floating enable
1709 if (*workspace == '~') {
1711 if (*workspace == '\0') {
1712 /* This assignment was *only* for floating */
1713 assignment->type = A_COMMAND;
1714 assignment->dest.command = sstrdup("floating enable");
1715 TAILQ_INSERT_TAIL(&assignments, assignment, assignments);
1718 /* Create a new assignment and continue afterwards */
1719 Assignment *floating = scalloc(sizeof(Assignment));
1720 match_copy(&(floating->match), match);
1721 floating->type = A_COMMAND;
1722 floating->dest.command = sstrdup("floating enable");
1723 TAILQ_INSERT_TAIL(&assignments, floating, assignments);
1727 assignment->type = A_TO_WORKSPACE;
1728 assignment->dest.workspace = workspace;
1729 TAILQ_INSERT_TAIL(&assignments, assignment, assignments);
1731 | TOKASSIGN match STR
1733 if (match_is_empty(¤t_match)) {
1734 ELOG("Match is empty, ignoring this assignment\n");
1737 printf("new assignment, using above criteria, to workspace %s\n", $3);
1738 Assignment *assignment = scalloc(sizeof(Assignment));
1739 assignment->match = current_match;
1740 assignment->type = A_TO_WORKSPACE;
1741 assignment->dest.workspace = $3;
1742 TAILQ_INSERT_TAIL(&assignments, assignment, assignments);
1754 config.ipc_socket_path = $2;
1761 config.restart_state_path = $2;
1766 TOKEXEC optional_no_startup_id STR
1768 struct Autostart *new = smalloc(sizeof(struct Autostart));
1770 new->no_startup_id = $2;
1771 TAILQ_INSERT_TAIL(&autostarts, new, autostarts);
1776 TOKEXEC_ALWAYS optional_no_startup_id STR
1778 struct Autostart *new = smalloc(sizeof(struct Autostart));
1780 new->no_startup_id = $2;
1781 TAILQ_INSERT_TAIL(&autostarts_always, new, autostarts_always);
1785 optional_border_width:
1786 /* empty */ { $$ = 2; } // 2 pixels is the default value for any type of border
1787 | NUMBER { $$ = $1; }
1790 optional_no_startup_id:
1791 /* empty */ { $$ = false; }
1792 | TOK_NO_STARTUP_ID { $$ = true; }
1798 ELOG("The terminal option is DEPRECATED and has no effect. "
1799 "Please remove it from your configuration file.\n");
1806 config.font = load_font($2, true);
1807 set_font(&config.font);
1808 printf("font %s\n", $2);
1815 TOKSINGLECOLOR colorpixel
1817 uint32_t *dest = $1;
1823 TOKCOLOR colorpixel colorpixel colorpixel
1825 struct Colortriple *dest = $1;
1828 dest->background = $3;
1831 | TOKCOLOR colorpixel colorpixel colorpixel colorpixel
1833 struct Colortriple *dest = $1;
1836 dest->background = $3;
1838 dest->indicator = $5;
1845 $$ = get_colorpixel($1);
1852 /* NULL */ { $$ = 0; }
1854 | binding_modifiers '+' binding_modifier { $$ = $1 | $3; }
1855 | binding_modifiers '+' { $$ = $1; }
1859 MODIFIER { $$ = $1; }
1860 | TOKCONTROL { $$ = BIND_CONTROL; }
1861 | TOKSHIFT { $$ = BIND_SHIFT; }
1864 popup_during_fullscreen:
1865 TOK_POPUP_DURING_FULLSCREEN popup_setting
1867 DLOG("popup_during_fullscreen setting: %d\n", $2);
1868 config.popup_during_fullscreen = $2;
1873 TOK_IGNORE { $$ = PDF_IGNORE; }
1874 | TOK_LEAVE_FULLSCREEN { $$ = PDF_LEAVE_FULLSCREEN; }