20 bool handle_message(char *msg, int msg_len, char *rsp)
24 char **args = malloc(cap * sizeof(char *));
28 for (int i = 0, j = 0; i < msg_len; i++) {
30 args[num++] = msg + j;
35 char **new = realloc(args, cap * sizeof(char *));
50 char **args_orig = args;
51 bool ret = process_message(args, num, rsp);
56 bool process_message(char **args, int num, char *rsp)
58 if (streq("window", *args)) {
59 return cmd_window(++args, --num);
60 } else if (streq("desktop", *args)) {
61 return cmd_desktop(++args, --num);
62 } else if (streq("monitor", *args)) {
63 return cmd_monitor(++args, --num);
64 } else if (streq("query", *args)) {
65 return cmd_query(++args, --num, rsp);
66 } else if (streq("tag", *args)) {
67 return cmd_tag(++args, --num, rsp);
68 } else if (streq("restore", *args)) {
69 return cmd_restore(++args, --num);
70 } else if (streq("control", *args)) {
71 return cmd_control(++args, --num);
72 } else if (streq("rule", *args)) {
73 return cmd_rule(++args, --num, rsp);
74 } else if (streq("pointer", *args)) {
75 return cmd_pointer(++args, --num);
76 } else if (streq("config", *args)) {
77 return cmd_config(++args, --num, rsp);
78 } else if (streq("quit", *args)) {
79 return cmd_quit(++args, --num);
85 bool cmd_window(char **args, int num)
90 coordinates_t ref = {mon, mon->desk, mon->desk->focus};
91 coordinates_t trg = ref;
93 if (*args[0] != OPT_CHR) {
94 if (node_from_desc(*args, &ref, &trg))
100 if (trg.node == NULL)
106 if (streq("-f", *args) || streq("--focus", *args)) {
107 coordinates_t dst = trg;
108 if (num > 1 && *(args + 1)[0] != OPT_CHR) {
110 if (!node_from_desc(*args, &trg, &dst))
113 focus_node(dst.monitor, dst.desktop, dst.node);
114 } else if (streq("-d", *args) || streq("--to-desktop", *args)) {
117 if (desktop_from_desc(*args, &trg, &dst)) {
118 if (transfer_node(trg.monitor, trg.desktop, trg.node, dst.monitor, dst.desktop, dst.desktop->focus)) {
119 trg.monitor = dst.monitor;
120 trg.desktop = dst.desktop;
125 } else if (streq("-m", *args) || streq("--to-monitor", *args)) {
130 if (monitor_from_desc(*args, &trg, &dst)) {
131 if (transfer_node(trg.monitor, trg.desktop, trg.node, dst.monitor, dst.monitor->desk, dst.monitor->desk->focus)) {
132 trg.monitor = dst.monitor;
133 trg.desktop = dst.monitor->desk;
138 } else if (streq("-w", *args) || streq("--to-window", *args)) {
143 if (node_from_desc(*args, &trg, &dst)) {
144 if (transfer_node(trg.monitor, trg.desktop, trg.node, dst.monitor, dst.desktop, dst.node)) {
145 trg.monitor = dst.monitor;
146 trg.desktop = dst.desktop;
151 } else if (streq("-s", *args) || streq("--swap", *args)) {
156 if (node_from_desc(*args, &trg, &dst)) {
157 if (swap_nodes(trg.monitor, trg.desktop, trg.node, dst.monitor, dst.desktop, dst.node)) {
158 if (trg.desktop != dst.desktop)
159 arrange(trg.monitor, trg.desktop);
160 trg.monitor = dst.monitor;
161 trg.desktop = dst.desktop;
167 } else if (streq("-t", *args) || streq("--toggle", *args)) {
171 char *key = strtok(*args, EQL_TOK);
172 char *val = strtok(NULL, EQL_TOK);
178 if (parse_bool(val, &b))
183 if (streq("fullscreen", key)) {
184 set_fullscreen(trg.node, (a == ALTER_SET ? b : !trg.node->client->fullscreen));
186 } else if (streq("floating", key)) {
187 set_floating(trg.node, (a == ALTER_SET ? b : !trg.node->client->floating));
189 } else if (streq("locked", key)) {
190 set_locked(trg.monitor, trg.desktop, trg.node, (a == ALTER_SET ? b : !trg.node->client->locked));
191 } else if (streq("sticky", key)) {
192 set_sticky(trg.monitor, trg.desktop, trg.node, (a == ALTER_SET ? b : !trg.node->client->sticky));
193 } else if (streq("visible", key)) {
194 set_presence(trg.monitor, trg.desktop, trg.node, (a == ALTER_SET ? b : !is_visible(trg.desktop, trg.node)));
196 } else if (streq("-p", *args) || streq("--presel", *args)) {
198 if (num < 1 || !is_tiled(trg.node->client)
199 || trg.desktop->layout != LAYOUT_TILED)
201 if (streq("cancel", *args)) {
205 if (parse_direction(*args, &dir)) {
206 double rat = trg.node->split_ratio;
207 if (num > 1 && *(args + 1)[0] != OPT_CHR) {
209 if (sscanf(*args, "%lf", &rat) != 1 || rat <= 0 || rat >= 1)
212 if (auto_cancel && trg.node->split_mode == MODE_MANUAL
213 && dir == trg.node->split_dir
214 && rat == trg.node->split_ratio) {
217 trg.node->split_mode = MODE_MANUAL;
218 trg.node->split_dir = dir;
219 trg.node->split_ratio = rat;
221 window_draw_border(trg.node, trg.desktop->focus == trg.node, mon == trg.monitor);
226 } else if (streq("-e", *args) || streq("--edge", *args)) {
231 if (!parse_direction(*args, &dir))
233 node_t *n = find_fence(trg.node, dir);
238 if (parse_fence_move(*args, &fmo)) {
239 move_fence(n, dir, fmo);
242 if (sscanf(*args, "%lf", &rat) == 1 && rat > 0 && rat < 1)
243 n->split_ratio = rat;
248 } else if (streq("-r", *args) || streq("--ratio", *args)) {
253 if (sscanf(*args, "%lf", &rat) == 1 && rat > 0 && rat < 1) {
254 trg.node->split_ratio = rat;
255 window_draw_border(trg.node, trg.desktop->focus == trg.node, mon == trg.monitor);
259 } else if (streq("-R", *args) || streq("--rotate", *args)) {
264 if (!parse_direction(*args, &dir))
266 node_t *n = find_fence(trg.node, dir);
271 if (parse_degree(*args, °)) {
277 } else if (streq("-c", *args) || streq("--close", *args)) {
280 window_close(trg.node);
281 } else if (streq("-k", *args) || streq("--kill", *args)) {
284 window_kill(trg.monitor, trg.desktop, trg.node);
294 arrange(trg.monitor, trg.desktop);
299 bool cmd_desktop(char **args, int num)
304 coordinates_t ref = {mon, mon->desk, NULL};
305 coordinates_t trg = ref;
307 if (*args[0] != OPT_CHR) {
308 if (desktop_from_desc(*args, &ref, &trg))
317 if (streq("-f", *args) || streq("--focus", *args)) {
318 coordinates_t dst = trg;
319 if (num > 1 && *(args + 1)[0] != OPT_CHR) {
321 if (!desktop_from_desc(*args, &trg, &dst))
324 if (auto_alternate && dst.desktop == mon->desk) {
325 desktop_select_t sel = {DESKTOP_STATUS_ALL, false, false};
326 history_find_desktop(HISTORY_OLDER, &trg, &dst, sel);
328 focus_node(dst.monitor, dst.desktop, dst.desktop->focus);
329 } else if (streq("-m", *args) || streq("--to-monitor", *args)) {
331 if (num < 1 || trg.monitor->desk_head == trg.monitor->desk_tail)
334 if (monitor_from_desc(*args, &trg, &dst)) {
335 transfer_desktop(trg.monitor, dst.monitor, trg.desktop);
336 trg.monitor = dst.monitor;
341 } else if (streq("-s", *args) || streq("--swap", *args)) {
346 if (desktop_from_desc(*args, &trg, &dst) && trg.monitor == dst.monitor)
347 swap_desktops(trg.monitor, trg.desktop, dst.monitor, dst.desktop);
350 } else if (streq("-l", *args) || streq("--layout", *args)) {
356 if (parse_cycle_direction(*args, &cyc))
357 change_layout(trg.monitor, trg.desktop, (trg.desktop->layout + 1) % 2);
358 else if (parse_layout(*args, &lyt))
359 change_layout(trg.monitor, trg.desktop, lyt);
362 } else if (streq("-n", *args) || streq("--rename", *args)) {
366 snprintf(trg.desktop->name, sizeof(trg.desktop->name), "%s", *args);
367 ewmh_update_desktop_names();
369 } else if (streq("-r", *args) || streq("--remove", *args)) {
370 if (trg.desktop->root == NULL
371 && trg.monitor->desk_head != trg.monitor->desk_tail) {
372 remove_desktop(trg.monitor, trg.desktop);
373 show_desktop(trg.monitor->desk);
379 } else if (streq("-c", *args) || streq("--cancel-presel", *args)) {
381 } else if (streq("-F", *args) || streq("--flip", *args)) {
386 if (parse_flip(*args, &flp)) {
387 flip_tree(trg.desktop->root, flp);
392 } else if (streq("-R", *args) || streq("--rotate", *args)) {
397 if (parse_degree(*args, °)) {
398 rotate_tree(trg.desktop->root, deg);
403 } else if (streq("-B", *args) || streq("--balance", *args)) {
404 balance_tree(trg.desktop->root);
406 } else if (streq("-C", *args) || streq("--circulate", *args)) {
411 if (parse_circulate_direction(*args, &cir)) {
412 circulate_leaves(trg.monitor, trg.desktop, cir);
424 arrange(trg.monitor, trg.desktop);
429 bool cmd_monitor(char **args, int num)
434 coordinates_t ref = {mon, NULL, NULL};
435 coordinates_t trg = ref;
437 if (*args[0] != OPT_CHR) {
438 if (monitor_from_desc(*args, &ref, &trg))
445 if (streq("-f", *args) || streq("--focus", *args)) {
446 coordinates_t dst = trg;
447 if (num > 1 && *(args + 1)[0] != OPT_CHR) {
449 if (!monitor_from_desc(*args, &trg, &dst))
452 if (auto_alternate && dst.monitor == mon) {
453 desktop_select_t sel = {DESKTOP_STATUS_ALL, false, false};
454 history_find_monitor(HISTORY_OLDER, &trg, &dst, sel);
456 focus_node(dst.monitor, dst.monitor->desk, dst.monitor->desk->focus);
457 } else if (streq("-d", *args) || streq("--reset-desktops", *args)) {
461 desktop_t *d = trg.monitor->desk_head;
462 while (num > 0 && d != NULL) {
463 snprintf(d->name, sizeof(d->name), "%s", *args);
469 add_desktop(trg.monitor, make_desktop(*args));
473 desktop_t *next = d->next;
475 focus_node(trg.monitor, d->prev, d->prev->focus);
476 merge_desktops(trg.monitor, d, mon, mon->desk);
477 remove_desktop(trg.monitor, d);
480 } else if (streq("-a", *args) || streq("--add-desktops", *args)) {
485 add_desktop(trg.monitor, make_desktop(*args));
488 } else if (streq("-r", *args) || streq("--remove-desktops", *args)) {
494 if (locate_desktop(*args, &dst) && dst.monitor->desk_head != dst.monitor->desk_tail && dst.desktop->root == NULL) {
495 remove_desktop(dst.monitor, dst.desktop);
496 show_desktop(dst.monitor->desk);
500 } else if (streq("-n", *args) || streq("--rename", *args)) {
504 snprintf(trg.monitor->name, sizeof(trg.monitor->name), "%s", *args);
506 } else if (streq("-s", *args) || streq("--swap", *args)) {
511 if (monitor_from_desc(*args, &trg, &dst))
512 swap_monitors(trg.monitor, dst.monitor);
524 bool cmd_tag(char **args, int num, char *rsp)
529 coordinates_t ref = {mon, mon->desk, mon->desk->focus};
530 coordinates_t trg = {NULL, NULL, NULL};
533 if (streq("-d", *args) || streq("--desktop", *args)) {
537 if (!desktop_from_desc(*args, &ref, &trg))
539 } else if (streq("-w", *args) || streq("--window", *args)) {
543 if (!node_from_desc(*args, &ref, &trg))
545 } else if (streq("-s", *args) || streq("--set-tags", *args)) {
547 if (num < 1 || trg.desktop == NULL)
550 if (streq("all", *args))
551 tf = (1 << num_tags) - 1;
556 if (parse_index(*args, &idx))
557 tag = get_tag_by_index(idx - 1);
559 tag = get_tag(*args);
564 if (trg.node == NULL)
565 tag_desktop(trg.monitor, trg.desktop, tf);
567 tag_node(trg.monitor, trg.desktop, trg.node, trg.desktop, tf);
569 } else if (streq("-t", *args) || streq("--toggle-tags", *args)) {
571 if (num < 1 || trg.desktop == NULL)
574 if (trg.node == NULL)
575 tf = trg.desktop->tags_field;
577 tf = trg.node->client->tags_field;
582 if (parse_bool_declaration(*args, &key, &value, &alt)) {
585 if (parse_index(key, &idx))
586 tag = get_tag_by_index(idx - 1);
590 if (alt == ALTER_SET) {
602 if (trg.node == NULL)
603 tag_desktop(trg.monitor, trg.desktop, tf);
605 tag_node(trg.monitor, trg.desktop, trg.node, trg.desktop, tf);
607 } else if (streq("-e", *args) || streq("--enumerate-tags", *args)) {
612 while (i < num_tags && num > 0) {
613 snprintf(tags[i]->name, sizeof(tags[i]->name), "%s", *args);
614 tags[i]->mask = 1 << i;
617 while (i < num_tags) {
618 remove_tag_by_index(i);
625 } else if (streq("-a", *args) || streq("--add", *args)) {
633 } else if (streq("-r", *args) || streq("--remove", *args)) {
639 if (parse_index(*args, &idx))
640 remove_tag_by_index(idx - 1);
645 } else if (streq("-l", *args) || streq("--list", *args)) {
656 bool cmd_query(char **args, int num, char *rsp)
658 coordinates_t ref = {mon, mon->desk, mon->desk->focus};
659 coordinates_t trg = {NULL, NULL, NULL};
660 domain_t dom = DOMAIN_TREE;
664 if (streq("-T", *args) || streq("--tree", *args)) {
665 dom = DOMAIN_TREE, d++;
666 } else if (streq("-M", *args) || streq("--monitors", *args)) {
667 dom = DOMAIN_MONITOR, d++;
668 } else if (streq("-D", *args) || streq("--desktops", *args)) {
669 dom = DOMAIN_DESKTOP, d++;
670 } else if (streq("-W", *args) || streq("--windows", *args)) {
671 dom = DOMAIN_WINDOW, d++;
672 } else if (streq("-H", *args) || streq("--history", *args)) {
673 dom = DOMAIN_HISTORY, d++;
674 } else if (streq("-S", *args) || streq("--stack", *args)) {
675 dom = DOMAIN_STACK, d++;
676 } else if (streq("-m", *args) || streq("--monitor", *args)) {
677 trg.monitor = ref.monitor;
678 if (num > 1 && *(args + 1)[0] != OPT_CHR) {
680 if (!monitor_from_desc(*args, &ref, &trg))
684 } else if (streq("-d", *args) || streq("--desktop", *args)) {
685 trg.monitor = ref.monitor;
686 trg.desktop = ref.desktop;
687 if (num > 1 && *(args + 1)[0] != OPT_CHR) {
689 if (!desktop_from_desc(*args, &ref, &trg))
693 } else if (streq("-w", *args) || streq("--window", *args)) {
695 if (num > 1 && *(args + 1)[0] != OPT_CHR) {
697 if (!node_from_desc(*args, &ref, &trg))
710 if (dom == DOMAIN_HISTORY)
711 query_history(trg, rsp);
712 else if (dom == DOMAIN_STACK)
714 else if (dom == DOMAIN_WINDOW)
715 query_windows(trg, rsp);
717 query_monitors(trg, dom, rsp);
722 bool cmd_rule(char **args, int num, char *rsp)
727 if (streq("-a", *args) || streq("--add", *args)) {
731 rule_t *rule = make_rule();
732 snprintf(rule->cause.name, sizeof(rule->cause.name), "%s", *args);
735 if (streq("--floating", *args)) {
736 rule->effect.floating = true;
737 } else if (streq("--fullscreen", *args)) {
738 rule->effect.fullscreen = true;
739 } else if (streq("--locked", *args)) {
740 rule->effect.locked = true;
741 } else if (streq("--sticky", *args)) {
742 rule->effect.sticky = true;
743 } else if (streq("--follow", *args)) {
744 rule->effect.follow = true;
745 } else if (streq("--focus", *args)) {
746 rule->effect.focus = true;
747 } else if (streq("--unmanage", *args)) {
748 rule->effect.unmanage = true;
749 } else if (streq("--one-shot", *args)) {
750 rule->one_shot = true;
751 } else if (streq("--tags", *args)) {
757 snprintf(rule->effect.tags, sizeof(rule->effect.tags), "%s", *args);
758 } else if (streq("-d", *args) || streq("--desktop", *args)) {
764 snprintf(rule->effect.desc, sizeof(rule->effect.desc), "%s", *args);
772 } else if (streq("-r", *args) || streq("--remove", *args)) {
778 if (parse_index(*args, &idx))
779 remove_rule_by_index(idx - 1);
780 else if (streq("tail", *args))
781 remove_rule(rule_tail);
782 else if (streq("head", *args))
783 remove_rule(rule_head);
785 remove_rule_by_name(*args);
788 } else if (streq("-l", *args) || streq("--list", *args)) {
790 list_rules(num > 0 ? *args : NULL, rsp);
800 bool cmd_pointer(char **args, int num)
805 if (streq("-t", *args) || streq("--track", *args)) {
810 if (sscanf(*args, "%i", &x) == 1 && sscanf(*(args + 1), "%i", &y) == 1)
814 } else if (streq("-g", *args) || streq("--grab", *args)) {
818 pointer_action_t pac;
819 if (parse_pointer_action(*args, &pac))
832 bool cmd_restore(char **args, int num)
837 if (streq("-T", *args) || streq("--tree", *args)) {
842 } else if (streq("-H", *args) || streq("--history", *args)) {
846 restore_history(*args);
847 } else if (streq("-S", *args) || streq("--stack", *args)) {
851 restore_stack(*args);
861 bool cmd_control(char **args, int num)
866 if (streq("--adopt-orphans", *args)) {
868 } else if (streq("--put-status", *args)) {
870 } else if (streq("--toggle-visibility", *args)) {
872 } else if (streq("--record-history", *args)) {
877 if (parse_bool(*args, &b))
890 bool cmd_config(char **args, int num, char *rsp)
894 coordinates_t ref = {mon, mon->desk, mon->desk->focus};
895 coordinates_t trg = {NULL, NULL, NULL};
896 if (*args[0] == OPT_CHR) {
897 if (streq("-d", *args) || streq("--desktop", *args)) {
901 if (!desktop_from_desc(*args, &ref, &trg))
903 } else if (streq("-m", *args) || streq("--monitor", *args)) {
907 if (!monitor_from_desc(*args, &ref, &trg))
915 return set_setting(trg, *args, *(args + 1));
917 return get_setting(trg, *args, rsp);
922 bool cmd_quit(char **args, int num)
924 if (num > 0 && sscanf(*args, "%i", &exit_status) != 1)
930 bool set_setting(coordinates_t loc, char *name, char *value)
932 #define DESKSET(k, v) \
933 if (loc.desktop != NULL) \
934 loc.desktop->k = v; \
935 else if (loc.monitor != NULL) \
936 for (desktop_t *d = loc.monitor->desk_head; d != NULL; d = d->next) \
939 for (monitor_t *m = mon_head; m != NULL; m = m->next) \
940 for (desktop_t *d = m->desk_head; d != NULL; d = d->next) \
942 if (streq("border_width", name)) {
944 if (sscanf(value, "%u", &bw) != 1)
946 DESKSET(border_width, bw)
947 } else if (streq("window_gap", name)) {
949 if (sscanf(value, "%i", &wg) != 1)
951 DESKSET(window_gap, wg)
954 } else if (streq(#k, name)) { \
956 if (sscanf(value, "%i", &v) != 1) \
958 if (loc.monitor != NULL) \
959 loc.monitor->k = v; \
961 for (monitor_t *m = mon_head; m!= NULL; m = m->next) \
964 MONSET(right_padding)
965 MONSET(bottom_padding)
968 } else if (streq("split_ratio", name)) {
970 if (sscanf(value, "%lf", &r) == 1 && r > 0 && r < 1)
975 } else if (streq("growth_factor", name)) {
977 if (sscanf(value, "%lf", &g) == 1 && g > 1)
982 #define SETCOLOR(s) \
983 } else if (streq(#s, name)) { \
984 snprintf(s, sizeof(s), "%s", value);
985 SETCOLOR(focused_border_color)
986 SETCOLOR(active_border_color)
987 SETCOLOR(normal_border_color)
988 SETCOLOR(presel_border_color)
989 SETCOLOR(focused_locked_border_color)
990 SETCOLOR(active_locked_border_color)
991 SETCOLOR(normal_locked_border_color)
992 SETCOLOR(focused_sticky_border_color)
993 SETCOLOR(active_sticky_border_color)
994 SETCOLOR(normal_sticky_border_color)
995 SETCOLOR(urgent_border_color)
997 } else if (streq("focus_follows_pointer", name)) {
999 if (parse_bool(value, &b) && b != focus_follows_pointer) {
1000 uint32_t values[] = {(focus_follows_pointer ? CLIENT_EVENT_MASK : CLIENT_EVENT_MASK_FFP)};
1001 for (monitor_t *m = mon_head; m != NULL; m = m->next)
1002 for (desktop_t *d = m->desk_head; d != NULL; d = d->next)
1003 for (node_t *n = first_extrema(d->root); n != NULL; n = next_leaf(n, d->root))
1004 xcb_change_window_attributes(dpy, n->client->window, XCB_CW_EVENT_MASK, values);
1005 if (focus_follows_pointer) {
1006 for (monitor_t *m = mon_head; m != NULL; m = m->next)
1007 window_hide(m->root);
1008 disable_motion_recorder();
1010 for (monitor_t *m = mon_head; m != NULL; m = m->next)
1011 window_show(m->root);
1012 enable_motion_recorder();
1014 focus_follows_pointer = b;
1019 #define SETBOOL(s) \
1020 } else if (streq(#s, name)) { \
1021 if (!parse_bool(value, &s)) \
1023 SETBOOL(borderless_monocle)
1024 SETBOOL(gapless_monocle)
1025 SETBOOL(pointer_follows_monitor)
1026 SETBOOL(apply_floating_atom)
1027 SETBOOL(auto_alternate)
1028 SETBOOL(auto_cancel)
1029 SETBOOL(history_aware_focus)
1030 SETBOOL(honor_ewmh_focus)
1036 for (monitor_t *m = mon_head; m != NULL; m = m->next)
1037 for (desktop_t *d = m->desk_head; d != NULL; d = d->next)
1043 bool get_setting(coordinates_t loc, char *name, char* rsp)
1045 if (streq("split_ratio", name))
1046 snprintf(rsp, BUFSIZ, "%lf", split_ratio);
1047 else if (streq("growth_factor", name))
1048 snprintf(rsp, BUFSIZ, "%lf", growth_factor);
1049 else if (streq("window_gap", name))
1050 if (loc.desktop == NULL)
1053 snprintf(rsp, BUFSIZ, "%i", loc.desktop->window_gap);
1054 else if (streq("border_width", name))
1055 if (loc.desktop == NULL)
1058 snprintf(rsp, BUFSIZ, "%u", loc.desktop->border_width);
1060 else if (streq(#k, name)) \
1061 if (loc.monitor == NULL) \
1064 snprintf(rsp, BUFSIZ, "%i", loc.monitor->k);
1066 MONGET(right_padding)
1067 MONGET(bottom_padding)
1068 MONGET(left_padding)
1070 #define GETCOLOR(s) \
1071 else if (streq(#s, name)) \
1072 snprintf(rsp, BUFSIZ, "%s", s);
1073 GETCOLOR(focused_border_color)
1074 GETCOLOR(active_border_color)
1075 GETCOLOR(normal_border_color)
1076 GETCOLOR(presel_border_color)
1077 GETCOLOR(focused_locked_border_color)
1078 GETCOLOR(active_locked_border_color)
1079 GETCOLOR(normal_locked_border_color)
1080 GETCOLOR(focused_sticky_border_color)
1081 GETCOLOR(active_sticky_border_color)
1082 GETCOLOR(normal_sticky_border_color)
1083 GETCOLOR(urgent_border_color)
1085 #define GETBOOL(s) \
1086 else if (streq(#s, name)) \
1087 snprintf(rsp, BUFSIZ, "%s", BOOLSTR(s));
1088 GETBOOL(borderless_monocle)
1089 GETBOOL(gapless_monocle)
1090 GETBOOL(focus_follows_pointer)
1091 GETBOOL(pointer_follows_monitor)
1092 GETBOOL(apply_floating_atom)
1093 GETBOOL(auto_alternate)
1094 GETBOOL(auto_cancel)
1095 GETBOOL(history_aware_focus)
1096 GETBOOL(honor_ewmh_focus)
1103 bool parse_bool(char *value, bool *b)
1105 if (streq("true", value) || streq("on", value)) {
1108 } else if (streq("false", value) || streq("off", value)) {
1115 bool parse_layout(char *s, layout_t *l)
1117 if (streq("monocle", s)) {
1118 *l = LAYOUT_MONOCLE;
1120 } else if (streq("tiled", s)) {
1127 bool parse_direction(char *s, direction_t *d)
1129 if (streq("right", s)) {
1132 } else if (streq("down", s)) {
1135 } else if (streq("left", s)) {
1138 } else if (streq("up", s)) {
1145 bool parse_cycle_direction(char *s, cycle_dir_t *d)
1147 if (streq("next", s)) {
1150 } else if (streq("prev", s)) {
1157 bool parse_circulate_direction(char *s, circulate_dir_t *d)
1159 if (streq("forward", s)) {
1160 *d = CIRCULATE_FORWARD;
1162 } else if (streq("backward", s)) {
1163 *d = CIRCULATE_BACKWARD;
1169 bool parse_history_direction(char *s, history_dir_t *d)
1171 if (streq("older", s)) {
1174 } else if (streq("newer", s)) {
1182 bool parse_flip(char *s, flip_t *f)
1184 if (streq("horizontal", s)) {
1185 *f = FLIP_HORIZONTAL;
1187 } else if (streq("vertical", s)) {
1194 bool parse_fence_move(char *s, fence_move_t *m)
1196 if (streq("push", s)) {
1199 } else if (streq("pull", s)) {
1206 bool parse_pointer_action(char *s, pointer_action_t *a)
1208 if (streq("move", s)) {
1211 } else if (streq("resize_corner", s)) {
1212 *a = ACTION_RESIZE_CORNER;
1214 } else if (streq("resize_side", s)) {
1215 *a = ACTION_RESIZE_SIDE;
1217 } else if (streq("focus", s)) {
1224 bool parse_degree(char *s, int *d)
1231 if ((i % 90) != 0) {
1239 bool parse_window_id(char *s, long int *i)
1243 long int ret = strtol(s, &end, 0);
1244 if (errno != 0 || *end != '\0')
1251 bool parse_bool_declaration(char *s, char **key, bool *value, alter_state_t *state)
1253 *key = strtok(s, EQL_TOK);
1254 char *v = strtok(NULL, EQL_TOK);
1256 *state = ALTER_TOGGLE;
1259 if (parse_bool(v, value)) {
1269 bool parse_index(char *s, int *i)
1272 if (sscanf(s, "^%i", &idx) != 1 || idx < 1)