1 /* * Copyright (c) 2012-2013 Bastien Dejean
4 * Redistribution and use in source and binary forms, with or without modification,
5 * are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation and/or
11 * other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
17 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 bool handle_message(char *msg, int msg_len, char *rsp)
47 char **args = malloc(cap * sizeof(char *));
51 for (int i = 0, j = 0; i < msg_len; i++) {
53 args[num++] = msg + j;
58 char **new = realloc(args, cap * sizeof(char *));
73 char **args_orig = args;
74 bool ret = process_message(args, num, rsp);
79 bool process_message(char **args, int num, char *rsp)
81 if (streq("window", *args)) {
82 return cmd_window(++args, --num);
83 } else if (streq("desktop", *args)) {
84 return cmd_desktop(++args, --num);
85 } else if (streq("monitor", *args)) {
86 return cmd_monitor(++args, --num);
87 } else if (streq("query", *args)) {
88 return cmd_query(++args, --num, rsp);
89 } else if (streq("restore", *args)) {
90 return cmd_restore(++args, --num);
91 } else if (streq("control", *args)) {
92 return cmd_control(++args, --num);
93 } else if (streq("rule", *args)) {
94 return cmd_rule(++args, --num, rsp);
95 } else if (streq("pointer", *args)) {
96 return cmd_pointer(++args, --num);
97 } else if (streq("config", *args)) {
98 return cmd_config(++args, --num, rsp);
99 } else if (streq("quit", *args)) {
100 return cmd_quit(++args, --num);
106 bool cmd_window(char **args, int num)
111 coordinates_t ref = {mon, mon->desk, mon->desk->focus};
112 coordinates_t trg = ref;
114 if (*args[0] != OPT_CHR) {
115 if (node_from_desc(*args, &ref, &trg))
121 if (trg.node == NULL)
127 if (streq("-f", *args) || streq("--focus", *args)) {
128 coordinates_t dst = trg;
129 if (num > 1 && *(args + 1)[0] != OPT_CHR) {
131 if (!node_from_desc(*args, &trg, &dst))
134 focus_node(dst.monitor, dst.desktop, dst.node);
135 } else if (streq("-d", *args) || streq("--to-desktop", *args)) {
138 if (desktop_from_desc(*args, &trg, &dst)) {
139 if (transfer_node(trg.monitor, trg.desktop, trg.node, dst.monitor, dst.desktop, dst.desktop->focus)) {
140 trg.monitor = dst.monitor;
141 trg.desktop = dst.desktop;
146 } else if (streq("-m", *args) || streq("--to-monitor", *args)) {
151 if (monitor_from_desc(*args, &trg, &dst)) {
152 if (transfer_node(trg.monitor, trg.desktop, trg.node, dst.monitor, dst.monitor->desk, dst.monitor->desk->focus)) {
153 trg.monitor = dst.monitor;
154 trg.desktop = dst.monitor->desk;
159 } else if (streq("-w", *args) || streq("--to-window", *args)) {
164 if (node_from_desc(*args, &trg, &dst)) {
165 if (transfer_node(trg.monitor, trg.desktop, trg.node, dst.monitor, dst.desktop, dst.node)) {
166 trg.monitor = dst.monitor;
167 trg.desktop = dst.desktop;
172 } else if (streq("-s", *args) || streq("--swap", *args)) {
177 if (node_from_desc(*args, &trg, &dst)) {
178 if (swap_nodes(trg.monitor, trg.desktop, trg.node, dst.monitor, dst.desktop, dst.node)) {
179 if (trg.desktop != dst.desktop)
180 arrange(trg.monitor, trg.desktop);
181 trg.monitor = dst.monitor;
182 trg.desktop = dst.desktop;
188 } else if (streq("-t", *args) || streq("--toggle", *args)) {
192 char *key = strtok(*args, EQL_TOK);
193 char *val = strtok(NULL, EQL_TOK);
199 if (parse_bool(val, &b))
204 if (streq("fullscreen", key)) {
205 set_fullscreen(trg.node, (a == ALTER_SET ? b : !trg.node->client->fullscreen));
207 } else if (streq("floating", key)) {
208 set_floating(trg.node, (a == ALTER_SET ? b : !trg.node->client->floating));
210 } else if (streq("locked", key)) {
211 set_locked(trg.monitor, trg.desktop, trg.node, (a == ALTER_SET ? b : !trg.node->client->locked));
212 } else if (streq("sticky", key)) {
213 set_sticky(trg.monitor, trg.desktop, trg.node, (a == ALTER_SET ? b : !trg.node->client->sticky));
214 } else if (streq("private", key)) {
215 set_private(trg.monitor, trg.desktop, trg.node, (a == ALTER_SET ? b : !trg.node->client->private));
217 } else if (streq("-p", *args) || streq("--presel", *args)) {
219 if (num < 1 || !is_tiled(trg.node->client)
220 || trg.desktop->layout != LAYOUT_TILED)
222 if (streq("cancel", *args)) {
226 if (parse_direction(*args, &dir)) {
227 double rat = trg.node->split_ratio;
228 if (num > 1 && *(args + 1)[0] != OPT_CHR) {
230 if (sscanf(*args, "%lf", &rat) != 1 || rat <= 0 || rat >= 1)
233 if (auto_cancel && trg.node->split_mode == MODE_MANUAL
234 && dir == trg.node->split_dir
235 && rat == trg.node->split_ratio) {
238 trg.node->split_mode = MODE_MANUAL;
239 trg.node->split_dir = dir;
240 trg.node->split_ratio = rat;
242 window_draw_border(trg.node, trg.desktop->focus == trg.node, mon == trg.monitor);
247 } else if (streq("-e", *args) || streq("--edge", *args)) {
252 if (!parse_direction(*args, &dir))
254 node_t *n = find_fence(trg.node, dir);
259 if (parse_fence_move(*args, &fmo)) {
260 move_fence(n, dir, fmo);
263 if (sscanf(*args, "%lf", &rat) == 1 && rat > 0 && rat < 1)
264 n->split_ratio = rat;
269 } else if (streq("-r", *args) || streq("--ratio", *args)) {
274 if (sscanf(*args, "%lf", &rat) == 1 && rat > 0 && rat < 1) {
275 trg.node->split_ratio = rat;
276 window_draw_border(trg.node, trg.desktop->focus == trg.node, mon == trg.monitor);
280 } else if (streq("-R", *args) || streq("--rotate", *args)) {
285 if (!parse_direction(*args, &dir))
287 node_t *n = find_fence(trg.node, dir);
292 if (parse_degree(*args, °)) {
298 } else if (streq("-c", *args) || streq("--close", *args)) {
301 window_close(trg.node);
302 } else if (streq("-k", *args) || streq("--kill", *args)) {
305 window_kill(trg.monitor, trg.desktop, trg.node);
315 arrange(trg.monitor, trg.desktop);
320 bool cmd_desktop(char **args, int num)
325 coordinates_t ref = {mon, mon->desk, NULL};
326 coordinates_t trg = ref;
328 if (*args[0] != OPT_CHR) {
329 if (desktop_from_desc(*args, &ref, &trg))
338 if (streq("-f", *args) || streq("--focus", *args)) {
339 coordinates_t dst = trg;
340 if (num > 1 && *(args + 1)[0] != OPT_CHR) {
342 if (!desktop_from_desc(*args, &trg, &dst))
345 if (auto_alternate && dst.desktop == mon->desk) {
346 desktop_select_t sel = {DESKTOP_STATUS_ALL, false, false};
347 history_find_desktop(HISTORY_OLDER, &trg, &dst, sel);
349 focus_node(dst.monitor, dst.desktop, dst.desktop->focus);
350 } else if (streq("-m", *args) || streq("--to-monitor", *args)) {
352 if (num < 1 || trg.monitor->desk_head == trg.monitor->desk_tail)
355 if (monitor_from_desc(*args, &trg, &dst)) {
356 transfer_desktop(trg.monitor, dst.monitor, trg.desktop);
357 trg.monitor = dst.monitor;
362 } else if (streq("-s", *args) || streq("--swap", *args)) {
367 if (desktop_from_desc(*args, &trg, &dst) && trg.monitor == dst.monitor)
368 swap_desktops(trg.monitor, trg.desktop, dst.monitor, dst.desktop);
371 } else if (streq("-l", *args) || streq("--layout", *args)) {
377 if (parse_cycle_direction(*args, &cyc))
378 change_layout(trg.monitor, trg.desktop, (trg.desktop->layout + 1) % 2);
379 else if (parse_layout(*args, &lyt))
380 change_layout(trg.monitor, trg.desktop, lyt);
383 } else if (streq("-n", *args) || streq("--rename", *args)) {
387 snprintf(trg.desktop->name, sizeof(trg.desktop->name), "%s", *args);
388 ewmh_update_desktop_names();
390 } else if (streq("-r", *args) || streq("--remove", *args)) {
391 if (trg.desktop->root == NULL
392 && trg.monitor->desk_head != trg.monitor->desk_tail) {
393 remove_desktop(trg.monitor, trg.desktop);
394 show_desktop(trg.monitor->desk);
400 } else if (streq("-c", *args) || streq("--cancel-presel", *args)) {
402 } else if (streq("-F", *args) || streq("--flip", *args)) {
407 if (parse_flip(*args, &flp)) {
408 flip_tree(trg.desktop->root, flp);
413 } else if (streq("-R", *args) || streq("--rotate", *args)) {
418 if (parse_degree(*args, °)) {
419 rotate_tree(trg.desktop->root, deg);
424 } else if (streq("-B", *args) || streq("--balance", *args)) {
425 balance_tree(trg.desktop->root);
427 } else if (streq("-C", *args) || streq("--circulate", *args)) {
432 if (parse_circulate_direction(*args, &cir)) {
433 circulate_leaves(trg.monitor, trg.desktop, cir);
445 arrange(trg.monitor, trg.desktop);
450 bool cmd_monitor(char **args, int num)
455 coordinates_t ref = {mon, NULL, NULL};
456 coordinates_t trg = ref;
458 if (*args[0] != OPT_CHR) {
459 if (monitor_from_desc(*args, &ref, &trg))
466 if (streq("-f", *args) || streq("--focus", *args)) {
467 coordinates_t dst = trg;
468 if (num > 1 && *(args + 1)[0] != OPT_CHR) {
470 if (!monitor_from_desc(*args, &trg, &dst))
473 if (auto_alternate && dst.monitor == mon) {
474 desktop_select_t sel = {DESKTOP_STATUS_ALL, false, false};
475 history_find_monitor(HISTORY_OLDER, &trg, &dst, sel);
477 focus_node(dst.monitor, dst.monitor->desk, dst.monitor->desk->focus);
478 } else if (streq("-d", *args) || streq("--reset-desktops", *args)) {
482 desktop_t *d = trg.monitor->desk_head;
483 while (num > 0 && d != NULL) {
484 snprintf(d->name, sizeof(d->name), "%s", *args);
490 add_desktop(trg.monitor, make_desktop(*args));
494 desktop_t *next = d->next;
496 focus_node(trg.monitor, d->prev, d->prev->focus);
497 merge_desktops(trg.monitor, d, mon, mon->desk);
498 remove_desktop(trg.monitor, d);
501 } else if (streq("-a", *args) || streq("--add-desktops", *args)) {
506 add_desktop(trg.monitor, make_desktop(*args));
509 } else if (streq("-r", *args) || streq("--remove-desktops", *args)) {
515 if (locate_desktop(*args, &dst) && dst.monitor->desk_head != dst.monitor->desk_tail && dst.desktop->root == NULL) {
516 remove_desktop(dst.monitor, dst.desktop);
517 show_desktop(dst.monitor->desk);
521 } else if (streq("-n", *args) || streq("--rename", *args)) {
525 snprintf(trg.monitor->name, sizeof(trg.monitor->name), "%s", *args);
527 } else if (streq("-s", *args) || streq("--swap", *args)) {
532 if (monitor_from_desc(*args, &trg, &dst))
533 swap_monitors(trg.monitor, dst.monitor);
545 bool cmd_query(char **args, int num, char *rsp)
547 coordinates_t ref = {mon, mon->desk, mon->desk->focus};
548 coordinates_t trg = {NULL, NULL, NULL};
549 domain_t dom = DOMAIN_TREE;
553 if (streq("-T", *args) || streq("--tree", *args)) {
554 dom = DOMAIN_TREE, d++;
555 } else if (streq("-M", *args) || streq("--monitors", *args)) {
556 dom = DOMAIN_MONITOR, d++;
557 } else if (streq("-D", *args) || streq("--desktops", *args)) {
558 dom = DOMAIN_DESKTOP, d++;
559 } else if (streq("-W", *args) || streq("--windows", *args)) {
560 dom = DOMAIN_WINDOW, d++;
561 } else if (streq("-H", *args) || streq("--history", *args)) {
562 dom = DOMAIN_HISTORY, d++;
563 } else if (streq("-S", *args) || streq("--stack", *args)) {
564 dom = DOMAIN_STACK, d++;
565 } else if (streq("-m", *args) || streq("--monitor", *args)) {
566 trg.monitor = ref.monitor;
567 if (num > 1 && *(args + 1)[0] != OPT_CHR) {
569 if (!monitor_from_desc(*args, &ref, &trg))
573 } else if (streq("-d", *args) || streq("--desktop", *args)) {
574 trg.monitor = ref.monitor;
575 trg.desktop = ref.desktop;
576 if (num > 1 && *(args + 1)[0] != OPT_CHR) {
578 if (!desktop_from_desc(*args, &ref, &trg))
582 } else if (streq("-w", *args) || streq("--window", *args)) {
584 if (num > 1 && *(args + 1)[0] != OPT_CHR) {
586 if (!node_from_desc(*args, &ref, &trg))
599 if (dom == DOMAIN_HISTORY)
600 query_history(trg, rsp);
601 else if (dom == DOMAIN_STACK)
603 else if (dom == DOMAIN_WINDOW)
604 query_windows(trg, rsp);
606 query_monitors(trg, dom, rsp);
611 bool cmd_rule(char **args, int num, char *rsp)
616 if (streq("-a", *args) || streq("--add", *args)) {
620 rule_t *rule = make_rule();
621 snprintf(rule->cause.name, sizeof(rule->cause.name), "%s", *args);
624 if (streq("--floating", *args)) {
625 rule->effect.floating = true;
626 } else if (streq("--fullscreen", *args)) {
627 rule->effect.fullscreen = true;
628 } else if (streq("--locked", *args)) {
629 rule->effect.locked = true;
630 } else if (streq("--sticky", *args)) {
631 rule->effect.sticky = true;
632 } else if (streq("--follow", *args)) {
633 rule->effect.follow = true;
634 } else if (streq("--focus", *args)) {
635 rule->effect.focus = true;
636 } else if (streq("--frame", *args)) {
637 rule->effect.frame = true;
638 } else if (streq("--private", *args)) {
639 rule->effect.private = true;
640 } else if (streq("--unmanage", *args)) {
641 rule->effect.unmanage = true;
642 } else if (streq("--one-shot", *args)) {
643 rule->one_shot = true;
644 } else if (streq("-d", *args) || streq("--desktop", *args)) {
650 snprintf(rule->effect.desc, sizeof(rule->effect.desc), "%s", *args);
658 } else if (streq("-r", *args) || streq("--remove", *args)) {
664 if (parse_index(*args, &idx))
665 remove_rule_by_index(idx - 1);
666 else if (streq("tail", *args))
667 remove_rule(rule_tail);
668 else if (streq("head", *args))
669 remove_rule(rule_head);
671 remove_rule_by_name(*args);
674 } else if (streq("-l", *args) || streq("--list", *args)) {
676 list_rules(num > 0 ? *args : NULL, rsp);
686 bool cmd_pointer(char **args, int num)
691 if (streq("-t", *args) || streq("--track", *args)) {
696 if (sscanf(*args, "%i", &x) == 1 && sscanf(*(args + 1), "%i", &y) == 1)
700 } else if (streq("-g", *args) || streq("--grab", *args)) {
704 pointer_action_t pac;
705 if (parse_pointer_action(*args, &pac))
718 bool cmd_restore(char **args, int num)
723 if (streq("-T", *args) || streq("--tree", *args)) {
728 } else if (streq("-H", *args) || streq("--history", *args)) {
732 restore_history(*args);
733 } else if (streq("-S", *args) || streq("--stack", *args)) {
737 restore_stack(*args);
747 bool cmd_control(char **args, int num)
752 if (streq("--adopt-orphans", *args)) {
754 } else if (streq("--put-status", *args)) {
756 } else if (streq("--toggle-visibility", *args)) {
758 } else if (streq("--record-history", *args)) {
763 if (parse_bool(*args, &b))
776 bool cmd_config(char **args, int num, char *rsp)
780 coordinates_t ref = {mon, mon->desk, mon->desk->focus};
781 coordinates_t trg = {NULL, NULL, NULL};
782 if (*args[0] == OPT_CHR) {
783 if (streq("-d", *args) || streq("--desktop", *args)) {
787 if (!desktop_from_desc(*args, &ref, &trg))
789 } else if (streq("-m", *args) || streq("--monitor", *args)) {
793 if (!monitor_from_desc(*args, &ref, &trg))
801 return set_setting(trg, *args, *(args + 1));
803 return get_setting(trg, *args, rsp);
808 bool cmd_quit(char **args, int num)
810 if (num > 0 && sscanf(*args, "%i", &exit_status) != 1)
816 bool set_setting(coordinates_t loc, char *name, char *value)
818 #define DESKSET(k, v) \
819 if (loc.desktop != NULL) \
820 loc.desktop->k = v; \
821 else if (loc.monitor != NULL) \
822 for (desktop_t *d = loc.monitor->desk_head; d != NULL; d = d->next) \
825 for (monitor_t *m = mon_head; m != NULL; m = m->next) \
826 for (desktop_t *d = m->desk_head; d != NULL; d = d->next) \
828 if (streq("border_width", name)) {
830 if (sscanf(value, "%u", &bw) != 1)
832 DESKSET(border_width, bw)
833 } else if (streq("window_gap", name)) {
835 if (sscanf(value, "%i", &wg) != 1)
837 DESKSET(window_gap, wg)
840 } else if (streq(#k, name)) { \
842 if (sscanf(value, "%i", &v) != 1) \
844 if (loc.monitor != NULL) \
845 loc.monitor->k = v; \
847 for (monitor_t *m = mon_head; m!= NULL; m = m->next) \
850 MONSET(right_padding)
851 MONSET(bottom_padding)
854 } else if (streq("split_ratio", name)) {
856 if (sscanf(value, "%lf", &r) == 1 && r > 0 && r < 1)
861 } else if (streq("growth_factor", name)) {
863 if (sscanf(value, "%lf", &g) == 1 && g > 1)
868 #define SETOPACITY(s) \
869 } else if (streq(#s, name)) { \
871 if (sscanf(value, "%lf", &o) == 1 && o >= 0 && o <= 1) \
875 SETOPACITY(focused_frame_opacity)
876 SETOPACITY(active_frame_opacity)
877 SETOPACITY(normal_frame_opacity)
879 #define SETCOLOR(s) \
880 } else if (streq(#s, name)) { \
881 snprintf(s, sizeof(s), "%s", value);
882 SETCOLOR(focused_border_color)
883 SETCOLOR(active_border_color)
884 SETCOLOR(normal_border_color)
885 SETCOLOR(presel_border_color)
886 SETCOLOR(focused_locked_border_color)
887 SETCOLOR(active_locked_border_color)
888 SETCOLOR(normal_locked_border_color)
889 SETCOLOR(focused_sticky_border_color)
890 SETCOLOR(active_sticky_border_color)
891 SETCOLOR(normal_sticky_border_color)
892 SETCOLOR(focused_private_border_color)
893 SETCOLOR(active_private_border_color)
894 SETCOLOR(normal_private_border_color)
895 SETCOLOR(urgent_border_color)
897 } else if (streq("focus_follows_pointer", name)) {
899 if (parse_bool(value, &b) && b != focus_follows_pointer) {
900 focus_follows_pointer = b;
901 for (monitor_t *m = mon_head; m != NULL; m = m->next)
902 for (desktop_t *d = m->desk_head; d != NULL; d = d->next)
903 for (node_t *n = first_extrema(d->root); n != NULL; n = next_leaf(n, d->root)) {
904 uint32_t values[] = {get_event_mask(n->client)};
905 xcb_change_window_attributes(dpy, n->client->window, XCB_CW_EVENT_MASK, values);
907 if (focus_follows_pointer) {
908 for (monitor_t *m = mon_head; m != NULL; m = m->next)
909 window_show(m->root);
910 enable_motion_recorder();
912 for (monitor_t *m = mon_head; m != NULL; m = m->next)
913 window_hide(m->root);
914 disable_motion_recorder();
921 } else if (streq(#s, name)) { \
922 if (!parse_bool(value, &s)) \
924 SETBOOL(borderless_monocle)
925 SETBOOL(gapless_monocle)
926 SETBOOL(pointer_follows_monitor)
927 SETBOOL(apply_floating_atom)
928 SETBOOL(auto_alternate)
930 SETBOOL(history_aware_focus)
931 SETBOOL(honor_ewmh_focus)
937 for (monitor_t *m = mon_head; m != NULL; m = m->next)
938 for (desktop_t *d = m->desk_head; d != NULL; d = d->next)
944 bool get_setting(coordinates_t loc, char *name, char* rsp)
946 if (streq("split_ratio", name))
947 snprintf(rsp, BUFSIZ, "%lf", split_ratio);
948 else if (streq("growth_factor", name))
949 snprintf(rsp, BUFSIZ, "%lf", growth_factor);
950 else if (streq("window_gap", name))
951 if (loc.desktop == NULL)
954 snprintf(rsp, BUFSIZ, "%i", loc.desktop->window_gap);
955 else if (streq("border_width", name))
956 if (loc.desktop == NULL)
959 snprintf(rsp, BUFSIZ, "%u", loc.desktop->border_width);
961 else if (streq(#k, name)) \
962 if (loc.monitor == NULL) \
965 snprintf(rsp, BUFSIZ, "%i", loc.monitor->k);
967 MONGET(right_padding)
968 MONGET(bottom_padding)
971 #define GETOPACITY(s) \
972 else if (streq(#s, name)) \
973 snprintf(rsp, BUFSIZ, "%lf", s);
974 GETOPACITY(focused_frame_opacity)
975 GETOPACITY(active_frame_opacity)
976 GETOPACITY(normal_frame_opacity)
978 #define GETCOLOR(s) \
979 else if (streq(#s, name)) \
980 snprintf(rsp, BUFSIZ, "%s", s);
981 GETCOLOR(focused_border_color)
982 GETCOLOR(active_border_color)
983 GETCOLOR(normal_border_color)
984 GETCOLOR(presel_border_color)
985 GETCOLOR(focused_locked_border_color)
986 GETCOLOR(active_locked_border_color)
987 GETCOLOR(normal_locked_border_color)
988 GETCOLOR(focused_sticky_border_color)
989 GETCOLOR(active_sticky_border_color)
990 GETCOLOR(normal_sticky_border_color)
991 GETCOLOR(urgent_border_color)
994 else if (streq(#s, name)) \
995 snprintf(rsp, BUFSIZ, "%s", BOOLSTR(s));
996 GETBOOL(borderless_monocle)
997 GETBOOL(gapless_monocle)
998 GETBOOL(focus_follows_pointer)
999 GETBOOL(pointer_follows_monitor)
1000 GETBOOL(apply_floating_atom)
1001 GETBOOL(auto_alternate)
1002 GETBOOL(auto_cancel)
1003 GETBOOL(history_aware_focus)
1004 GETBOOL(honor_ewmh_focus)
1011 bool parse_bool(char *value, bool *b)
1013 if (streq("true", value) || streq("on", value)) {
1016 } else if (streq("false", value) || streq("off", value)) {
1023 bool parse_layout(char *s, layout_t *l)
1025 if (streq("monocle", s)) {
1026 *l = LAYOUT_MONOCLE;
1028 } else if (streq("tiled", s)) {
1035 bool parse_direction(char *s, direction_t *d)
1037 if (streq("right", s)) {
1040 } else if (streq("down", s)) {
1043 } else if (streq("left", s)) {
1046 } else if (streq("up", s)) {
1053 bool parse_cycle_direction(char *s, cycle_dir_t *d)
1055 if (streq("next", s)) {
1058 } else if (streq("prev", s)) {
1065 bool parse_circulate_direction(char *s, circulate_dir_t *d)
1067 if (streq("forward", s)) {
1068 *d = CIRCULATE_FORWARD;
1070 } else if (streq("backward", s)) {
1071 *d = CIRCULATE_BACKWARD;
1077 bool parse_history_direction(char *s, history_dir_t *d)
1079 if (streq("older", s)) {
1082 } else if (streq("newer", s)) {
1090 bool parse_flip(char *s, flip_t *f)
1092 if (streq("horizontal", s)) {
1093 *f = FLIP_HORIZONTAL;
1095 } else if (streq("vertical", s)) {
1102 bool parse_fence_move(char *s, fence_move_t *m)
1104 if (streq("push", s)) {
1107 } else if (streq("pull", s)) {
1114 bool parse_pointer_action(char *s, pointer_action_t *a)
1116 if (streq("move", s)) {
1119 } else if (streq("resize_corner", s)) {
1120 *a = ACTION_RESIZE_CORNER;
1122 } else if (streq("resize_side", s)) {
1123 *a = ACTION_RESIZE_SIDE;
1125 } else if (streq("focus", s)) {
1132 bool parse_degree(char *s, int *d)
1139 if ((i % 90) != 0) {
1147 bool parse_window_id(char *s, long int *i)
1151 long int ret = strtol(s, &end, 0);
1152 if (errno != 0 || *end != '\0')
1159 bool parse_bool_declaration(char *s, char **key, bool *value, alter_state_t *state)
1161 *key = strtok(s, EQL_TOK);
1162 char *v = strtok(NULL, EQL_TOK);
1164 *state = ALTER_TOGGLE;
1167 if (parse_bool(v, value)) {
1177 bool parse_index(char *s, int *i)
1180 if (sscanf(s, "^%i", &idx) != 1 || idx < 1)