16 void process_message(char *msg, char *rsp)
18 char *cmd = strtok(msg, TOK_SEP);
23 if (strcmp(cmd, "get") == 0) {
24 char *name = strtok(NULL, TOK_SEP);
25 get_setting(name, rsp);
27 } else if (strcmp(cmd, "set") == 0) {
28 char *name = strtok(NULL, TOK_SEP);
29 char *value = strtok(NULL, TOK_SEP);
30 set_setting(name, value, rsp);
32 } else if (strcmp(cmd, "list") == 0) {
33 char *name = strtok(NULL, TOK_SEP);
35 desktop_location_t loc;
36 if (locate_desktop(name, &loc))
37 list(loc.desktop, loc.desktop->root, rsp, 0);
39 list(mon->desk, mon->desk->root, rsp, 0);
42 } else if (strcmp(cmd, "list_monitors") == 0) {
43 char *arg = strtok(NULL, TOK_SEP);
45 if (parse_list_option(arg, &opt))
46 list_monitors(opt, rsp);
48 } else if (strcmp(cmd, "list_desktops") == 0) {
49 char *arg = strtok(NULL, TOK_SEP);
51 if (parse_list_option(arg, &opt))
52 list_desktops(mon, opt, 0, rsp);
54 } else if (strcmp(cmd, "list_windows") == 0) {
57 } else if (strcmp(cmd, "list_history") == 0) {
60 } else if (strcmp(cmd, "list_rules") == 0) {
63 } else if (strcmp(cmd, "close") == 0) {
64 window_close(mon->desk->focus);
66 } else if (strcmp(cmd, "kill") == 0) {
67 window_kill(mon->desk, mon->desk->focus);
68 } else if (strcmp(cmd, "rotate") == 0) {
69 char *deg = strtok(NULL, TOK_SEP);
72 if (parse_rotate(deg, &r))
73 rotate_tree(mon->desk->root, r);
75 } else if (strcmp(cmd, "flip") == 0) {
76 char *flp = strtok(NULL, TOK_SEP);
79 if (parse_flip(flp, &f))
80 flip_tree(mon->desk->root, f);
82 } else if (strcmp(cmd, "balance") == 0) {
83 balance_tree(mon->desk->root);
84 } else if (strcmp(cmd, "grab_pointer") == 0) {
85 char *pac = strtok(NULL, TOK_SEP);
88 if (parse_pointer_action(pac, &a))
92 } else if (strcmp(cmd, "track_pointer") == 0) {
93 char *arg1 = strtok(NULL, TOK_SEP);
94 char *arg2 = strtok(NULL, TOK_SEP);
95 if (arg1 == NULL || arg2 == NULL)
98 if (sscanf(arg1, "%i", &root_x) == 1 && sscanf(arg2, "%i", &root_y) == 1)
99 track_pointer(root_x, root_y);
101 } else if (strcmp(cmd, "ungrab_pointer") == 0) {
104 } else if (strcmp(cmd, "layout") == 0) {
105 char *lyt = strtok(NULL, TOK_SEP);
108 if (parse_layout(lyt, &y)) {
109 char *name = strtok(NULL, TOK_SEP);
111 mon->desk->layout = y;
113 desktop_location_t loc;
115 if (locate_desktop(name, &loc))
116 loc.desktop->layout = y;
117 } while ((name = strtok(NULL, TOK_SEP)) != NULL);
122 } else if (strcmp(cmd, "cycle_layout") == 0) {
123 if (mon->desk->layout == LAYOUT_MONOCLE)
124 mon->desk->layout = LAYOUT_TILED;
126 mon->desk->layout = LAYOUT_MONOCLE;
128 } else if (strcmp(cmd, "shift") == 0) {
129 char *dir = strtok(NULL, TOK_SEP);
132 if (parse_direction(dir, &d))
133 swap_nodes(mon->desk->focus, focus_by_distance ? nearest_neighbor(mon->desk, mon->desk->focus, d) : find_neighbor(mon->desk->focus, d));
135 } else if (strcmp(cmd, "toggle_fullscreen") == 0) {
136 if (mon->desk->focus != NULL)
137 toggle_fullscreen(mon, mon->desk, mon->desk->focus);
139 } else if (strcmp(cmd, "toggle_floating") == 0) {
140 toggle_floating(mon->desk, mon->desk->focus);
141 } else if (strcmp(cmd, "toggle_locked") == 0) {
142 if (mon->desk->focus != NULL)
143 toggle_locked(mon, mon->desk, mon->desk->focus);
145 } else if (strcmp(cmd, "toggle_visibility") == 0) {
148 } else if (strcmp(cmd, "pad") == 0) {
149 char *name = strtok(NULL, TOK_SEP);
151 monitor_t *m = find_monitor(name);
153 char args[BUFSIZ] = {0}, *s;
154 while ((s = strtok(NULL, TOK_SEP)) != NULL) {
155 strncat(args, s, REMLEN(args));
156 strncat(args, TOK_SEP, REMLEN(args));
158 if (strlen(args) > 0) {
159 sscanf(args, "%i %i %i %i", &m->top_padding, &m->right_padding, &m->bottom_padding, &m->left_padding);
162 snprintf(rsp, BUFSIZ, "%i %i %i %i\n", m->top_padding, m->right_padding, m->bottom_padding, m->left_padding);
167 } else if (strcmp(cmd, "ratio") == 0) {
169 if (mon->desk->focus == NULL || (value = strtok(NULL, TOK_SEP)) == NULL ||
170 sscanf(value, "%lf", &mon->desk->focus->split_ratio) != 1)
172 } else if (strcmp(cmd, "cancel") == 0) {
173 split_mode = MODE_AUTOMATIC;
174 window_draw_border(mon->desk->focus, true, true);
176 } else if (strcmp(cmd, "presel") == 0) {
177 if (mon->desk->focus == NULL || !is_tiled(mon->desk->focus->client) || mon->desk->layout != LAYOUT_TILED)
179 char *dir = strtok(NULL, TOK_SEP);
182 if (parse_direction(dir, &d)) {
183 split_mode = MODE_MANUAL;
185 char *rat = strtok(NULL, TOK_SEP);
187 sscanf(rat, "%lf", &mon->desk->focus->split_ratio);
188 window_draw_border(mon->desk->focus, true, true);
192 } else if (strcmp(cmd, "push") == 0 || strcmp(cmd, "pull") == 0) {
193 char *dir = strtok(NULL, TOK_SEP);
197 if (parse_fence_move(cmd, &m) && parse_direction(dir, &d))
198 move_fence(mon->desk->focus, d, m);
200 } else if (strcmp(cmd, "drop_to_monitor") == 0) {
201 char *dir = strtok(NULL, TOK_SEP);
204 if (parse_cycle_direction(dir, &d)) {
207 m = ((mon->next == NULL ? mon_head : mon->next));
209 m = ((mon->prev == NULL ? mon_tail : mon->prev));
210 transfer_node(mon, mon->desk, m, m->desk, mon->desk->focus);
211 char *opt = strtok(NULL, TOK_SEP);
213 if (parse_send_option(opt, &o) && o == SEND_OPTION_FOLLOW)
214 focus_node(m, m->desk, m->desk->focus);
218 } else if (strcmp(cmd, "send_to_monitor") == 0) {
219 char *name = strtok(NULL, TOK_SEP);
221 monitor_t *m = find_monitor(name);
222 if (m != NULL && m != mon) {
223 transfer_node(mon, mon->desk, m, m->desk, mon->desk->focus);
224 char *opt = strtok(NULL, TOK_SEP);
226 if (parse_send_option(opt, &o) && o == SEND_OPTION_FOLLOW)
227 focus_node(m, m->desk, m->desk->focus);
231 } else if (strcmp(cmd, "drop_to") == 0) {
232 char *dir = strtok(NULL, TOK_SEP);
235 if (parse_cycle_direction(dir, &c)) {
238 d = ((mon->desk->next == NULL ? mon->desk_head : mon->desk->next));
240 d = ((mon->desk->prev == NULL ? mon->desk_tail : mon->desk->prev));
241 transfer_node(mon, mon->desk, mon, d, mon->desk->focus);
242 char *opt = strtok(NULL, TOK_SEP);
244 if (parse_send_option(opt, &o) && o == SEND_OPTION_FOLLOW)
245 focus_node(mon, d, d->focus);
249 } else if (strcmp(cmd, "send_to") == 0) {
250 char *name = strtok(NULL, TOK_SEP);
252 desktop_location_t loc;
253 if (locate_desktop(name, &loc)) {
254 transfer_node(mon, mon->desk, loc.monitor, loc.desktop, mon->desk->focus);
255 char *opt = strtok(NULL, TOK_SEP);
257 if (parse_send_option(opt, &o) && o == SEND_OPTION_FOLLOW)
258 focus_node(loc.monitor, loc.desktop, loc.desktop->focus);
262 } else if (strcmp(cmd, "rename_monitor") == 0) {
263 char *cur_name = strtok(NULL, TOK_SEP);
264 if (cur_name != NULL) {
265 monitor_t *m = find_monitor(cur_name);
267 char *new_name = strtok(NULL, TOK_SEP);
268 if (new_name != NULL) {
269 strncpy(m->name, new_name, sizeof(m->name));
274 } else if (strcmp(cmd, "rename") == 0) {
275 char *cur_name = strtok(NULL, TOK_SEP);
276 if (cur_name != NULL) {
277 desktop_location_t loc;
278 if (locate_desktop(cur_name, &loc)) {
279 char *new_name = strtok(NULL, TOK_SEP);
280 if (new_name != NULL) {
281 strncpy(loc.desktop->name, new_name, sizeof(loc.desktop->name));
282 ewmh_update_desktop_names();
287 } else if (strcmp(cmd, "use_monitor") == 0) {
288 char *name = strtok(NULL, TOK_SEP);
290 monitor_t *m = find_monitor(name);
292 if (auto_alternate && m == mon && last_mon != NULL)
293 focus_node(last_mon, last_mon->desk, last_mon->desk->focus);
295 focus_node(m, m->desk, m->desk->focus);
299 } else if (strcmp(cmd, "use") == 0) {
300 char *name = strtok(NULL, TOK_SEP);
302 desktop_location_t loc;
303 if (locate_desktop(name, &loc)) {
304 if (auto_alternate && loc.desktop == mon->desk && mon->last_desk != NULL)
305 focus_node(mon, mon->last_desk, mon->last_desk->focus);
307 focus_node(loc.monitor, loc.desktop, loc.desktop->focus);
311 } else if (strcmp(cmd, "cycle_monitor") == 0) {
312 char *dir = strtok(NULL, TOK_SEP);
315 if (parse_cycle_direction(dir, &d))
318 } else if (strcmp(cmd, "cycle_desktop") == 0) {
319 char *dir = strtok(NULL, TOK_SEP);
322 if (parse_cycle_direction(dir, &d)) {
324 char *skip = strtok(NULL, TOK_SEP);
325 if (parse_skip_desktop(skip, &k))
326 cycle_desktop(mon, mon->desk, d, k);
329 } else if (strcmp(cmd, "cycle") == 0) {
330 if (mon->desk->focus != NULL && mon->desk->focus->client->fullscreen)
332 char *dir = strtok(NULL, TOK_SEP);
335 if (parse_cycle_direction(dir, &d)) {
337 char *skip = strtok(NULL, TOK_SEP);
338 if (parse_skip_client(skip, &k))
339 cycle_leaf(mon, mon->desk, mon->desk->focus, d, k);
343 } else if (strcmp(cmd, "nearest") == 0) {
344 if (mon->desk->focus != NULL && mon->desk->focus->client->fullscreen)
346 char *arg = strtok(NULL, TOK_SEP);
349 if (parse_nearest_argument(arg, &a)) {
351 char *skip = strtok(NULL, TOK_SEP);
352 if (parse_skip_client(skip, &k))
353 nearest_leaf(mon, mon->desk, mon->desk->focus, a, k);
357 } else if (strcmp(cmd, "biggest") == 0) {
358 node_t *n = find_biggest(mon->desk);
360 snprintf(rsp, BUFSIZ, "0x%X", n->client->window);
362 } else if (strcmp(cmd, "circulate") == 0) {
363 if (mon->desk->layout == LAYOUT_MONOCLE
364 || (mon->desk->focus != NULL && !is_tiled(mon->desk->focus->client)))
366 char *dir = strtok(NULL, TOK_SEP);
369 if (parse_circulate_direction(dir, &d))
370 circulate_leaves(mon, mon->desk, d);
372 } else if (strcmp(cmd, "rule") == 0) {
373 char *name = strtok(NULL, TOK_SEP);
375 rule_t *rule = make_rule();
376 strncpy(rule->cause.name, name, sizeof(rule->cause.name));
377 char *arg = strtok(NULL, TOK_SEP);
378 while (arg != NULL) {
379 if (strcmp(arg, "floating") == 0) {
380 rule->effect.floating = true;
381 } else if (strcmp(arg, "follow") == 0) {
382 rule->effect.follow = true;
384 desktop_location_t loc;
385 if (locate_desktop(arg, &loc)) {
386 rule->effect.monitor = loc.monitor;
387 rule->effect.desktop = loc.desktop;
390 arg = strtok(NULL, TOK_SEP);
395 } else if (strcmp(cmd, "remove_rule") == 0) {
398 while ((arg = strtok(NULL, TOK_SEP)) != NULL)
399 if (sscanf(arg, "%X", &uid) > 0)
400 remove_rule_by_uid(uid);
402 } else if (strcmp(cmd, "swap") == 0) {
403 node_t *last_focus = history_get(mon->desk->history, 1);
404 swap_nodes(mon->desk->focus, last_focus);
405 char *opt = strtok(NULL, TOK_SEP);
407 if (parse_swap_option(opt, &o) && o == SWAP_OPTION_SWAP_FOCUS)
408 focus_node(mon, mon->desk, last_focus);
409 } else if (strcmp(cmd, "alternate") == 0) {
410 focus_node(mon, mon->desk, history_get(mon->desk->history, 1));
412 } else if (strcmp(cmd, "alternate_desktop") == 0) {
413 if (mon->last_desk != NULL)
414 focus_node(mon, mon->last_desk, mon->last_desk->focus);
415 } else if (strcmp(cmd, "alternate_monitor") == 0) {
416 if (last_mon != NULL)
417 focus_node(last_mon, last_mon->desk, last_mon->desk->focus);
418 } else if (strcmp(cmd, "add_in") == 0) {
419 char *name = strtok(NULL, TOK_SEP);
421 monitor_t *m = find_monitor(name);
423 for (name = strtok(NULL, TOK_SEP); name != NULL; name = strtok(NULL, TOK_SEP))
424 add_desktop(m, make_desktop(name));
427 } else if (strcmp(cmd, "add") == 0) {
428 for (char *name = strtok(NULL, TOK_SEP); name != NULL; name = strtok(NULL, TOK_SEP))
429 add_desktop(mon, make_desktop(name));
431 } else if (strcmp(cmd, "remove_desktop") == 0) {
432 for (char *name = strtok(NULL, TOK_SEP); name != NULL; name = strtok(NULL, TOK_SEP)) {
433 desktop_location_t loc;
434 if (locate_desktop(name, &loc)) {
435 if (loc.desktop->root == NULL && loc.monitor->desk_head != loc.monitor->desk_tail)
436 remove_desktop(loc.monitor, loc.desktop);
439 desktop_show(mon->desk);
442 } else if (strcmp(cmd, "send_desktop_to") == 0) {
443 if (mon->desk_head == mon->desk_tail)
445 char *name = strtok(NULL, TOK_SEP);
447 monitor_t *m = find_monitor(name);
448 if (m != NULL && m != mon) {
449 char *opt = strtok(NULL, TOK_SEP);
451 if (!parse_send_option(opt, &o))
453 desktop_t *d = mon->desk;
454 transfer_desktop(mon, m, d);
455 if (o == SEND_OPTION_FOLLOW)
456 focus_node(m, d, d->focus);
457 else if (o == SEND_OPTION_DONT_FOLLOW)
462 } else if (strcmp(cmd, "focus") == 0) {
463 if (mon->desk->focus == NULL || mon->desk->focus->client->fullscreen)
465 char *dir = strtok(NULL, TOK_SEP);
468 if (parse_direction(dir, &d)) {
470 if (focus_by_distance)
471 n = nearest_neighbor(mon->desk, mon->desk->focus, d);
473 n = find_neighbor(mon->desk->focus, d);
474 focus_node(mon, mon->desk, n);
478 } else if (strcmp(cmd, "put_status") == 0) {
481 } else if (strcmp(cmd, "adopt_orphans") == 0) {
484 } else if (strcmp(cmd, "restore_layout") == 0) {
485 char *arg = strtok(NULL, TOK_SEP);
488 } else if (strcmp(cmd, "restore_history") == 0) {
489 char *arg = strtok(NULL, TOK_SEP);
490 restore_history(arg);
492 } else if (strcmp(cmd, "quit") == 0) {
493 char *arg = strtok(NULL, TOK_SEP);
495 sscanf(arg, "%i", &exit_status);
499 snprintf(rsp, BUFSIZ, "unknown command: %s", cmd);
503 arrange(mon, mon->desk);
506 void set_setting(char *name, char *value, char *rsp)
508 if (name == NULL || value == NULL)
511 if (strcmp(name, "border_width") == 0) {
512 sscanf(value, "%u", &border_width);
513 } else if (strcmp(name, "window_gap") == 0) {
514 sscanf(value, "%i", &window_gap);
515 } else if (strcmp(name, "split_ratio") == 0) {
516 sscanf(value, "%lf", &split_ratio);
517 } else if (strcmp(name, "left_padding") == 0) {
518 sscanf(value, "%i", &mon->left_padding);
519 } else if (strcmp(name, "right_padding") == 0) {
520 sscanf(value, "%i", &mon->right_padding);
521 } else if (strcmp(name, "top_padding") == 0) {
522 sscanf(value, "%i", &mon->top_padding);
523 } else if (strcmp(name, "bottom_padding") == 0) {
524 sscanf(value, "%i", &mon->bottom_padding);
525 } else if (strcmp(name, "focused_border_color") == 0) {
526 strncpy(focused_border_color, value, sizeof(focused_border_color));
527 focused_border_color_pxl = get_color(focused_border_color);
528 } else if (strcmp(name, "active_border_color") == 0) {
529 strncpy(active_border_color, value, sizeof(active_border_color));
530 active_border_color_pxl = get_color(active_border_color);
531 } else if (strcmp(name, "normal_border_color") == 0) {
532 strncpy(normal_border_color, value, sizeof(normal_border_color));
533 normal_border_color_pxl = get_color(normal_border_color);
534 } else if (strcmp(name, "presel_border_color") == 0) {
535 strncpy(presel_border_color, value, sizeof(presel_border_color));
536 presel_border_color_pxl = get_color(presel_border_color);
537 } else if (strcmp(name, "focused_locked_border_color") == 0) {
538 strncpy(focused_locked_border_color, value, sizeof(focused_locked_border_color));
539 focused_locked_border_color_pxl = get_color(focused_locked_border_color);
540 } else if (strcmp(name, "active_locked_border_color") == 0) {
541 strncpy(active_locked_border_color, value, sizeof(active_locked_border_color));
542 active_locked_border_color_pxl = get_color(active_locked_border_color);
543 } else if (strcmp(name, "normal_locked_border_color") == 0) {
544 strncpy(normal_locked_border_color, value, sizeof(normal_locked_border_color));
545 normal_locked_border_color_pxl = get_color(normal_locked_border_color);
546 } else if (strcmp(name, "urgent_border_color") == 0) {
547 strncpy(urgent_border_color, value, sizeof(urgent_border_color));
548 urgent_border_color_pxl = get_color(urgent_border_color);
549 } else if (strcmp(name, "borderless_monocle") == 0) {
551 if (parse_bool(value, &b))
552 borderless_monocle = b;
553 } else if (strcmp(name, "gapless_monocle") == 0) {
555 if (parse_bool(value, &b))
557 } else if (strcmp(name, "focus_follows_pointer") == 0) {
559 if (parse_bool(value, &b) && b != focus_follows_pointer) {
560 uint32_t values[] = {(focus_follows_pointer ? CLIENT_EVENT_MASK : CLIENT_EVENT_MASK_FFP)};
561 for (monitor_t *m = mon_head; m != NULL; m = m->next)
562 for (desktop_t *d = m->desk_head; d != NULL; d = d->next)
563 for (node_t *n = first_extrema(d->root); n != NULL; n = next_leaf(n, d->root))
564 xcb_change_window_attributes(dpy, n->client->window, XCB_CW_EVENT_MASK, values);
565 if (focus_follows_pointer)
566 disable_motion_recorder();
568 enable_motion_recorder();
569 focus_follows_pointer = b;
572 } else if (strcmp(name, "pointer_follows_monitor") == 0) {
574 if (parse_bool(value, &b))
575 pointer_follows_monitor = b;
577 } else if (strcmp(name, "adaptative_raise") == 0) {
579 if (parse_bool(value, &b))
580 adaptative_raise = b;
582 } else if (strcmp(name, "apply_shadow_property") == 0) {
584 if (parse_bool(value, &b))
585 apply_shadow_property = b;
587 } else if (strcmp(name, "auto_alternate") == 0) {
589 if (parse_bool(value, &b))
592 } else if (strcmp(name, "focus_by_distance") == 0) {
594 if (parse_bool(value, &b))
595 focus_by_distance = b;
597 } else if (strcmp(name, "wm_name") == 0) {
598 strncpy(wm_name, value, sizeof(wm_name));
599 ewmh_update_wm_name();
602 snprintf(rsp, BUFSIZ, "unknown setting: %s", name);
606 arrange(mon, mon->desk);
609 void get_setting(char *name, char* rsp)
614 if (strcmp(name, "border_width") == 0)
615 snprintf(rsp, BUFSIZ, "%u", border_width);
616 else if (strcmp(name, "window_gap") == 0)
617 snprintf(rsp, BUFSIZ, "%i", window_gap);
618 else if (strcmp(name, "split_ratio") == 0)
619 snprintf(rsp, BUFSIZ, "%lf", split_ratio);
620 else if (strcmp(name, "left_padding") == 0)
621 snprintf(rsp, BUFSIZ, "%i", mon->left_padding);
622 else if (strcmp(name, "right_padding") == 0)
623 snprintf(rsp, BUFSIZ, "%i", mon->right_padding);
624 else if (strcmp(name, "top_padding") == 0)
625 snprintf(rsp, BUFSIZ, "%i", mon->top_padding);
626 else if (strcmp(name, "bottom_padding") == 0)
627 snprintf(rsp, BUFSIZ, "%i", mon->bottom_padding);
628 else if (strcmp(name, "focused_border_color") == 0)
629 snprintf(rsp, BUFSIZ, "%s (%06X)", focused_border_color, focused_border_color_pxl);
630 else if (strcmp(name, "active_border_color") == 0)
631 snprintf(rsp, BUFSIZ, "%s (%06X)", active_border_color, active_border_color_pxl);
632 else if (strcmp(name, "normal_border_color") == 0)
633 snprintf(rsp, BUFSIZ, "%s (%06X)", normal_border_color, normal_border_color_pxl);
634 else if (strcmp(name, "presel_border_color") == 0)
635 snprintf(rsp, BUFSIZ, "%s (%06X)", presel_border_color, presel_border_color_pxl);
636 else if (strcmp(name, "focused_locked_border_color") == 0)
637 snprintf(rsp, BUFSIZ, "%s (%06X)", focused_locked_border_color, focused_locked_border_color_pxl);
638 else if (strcmp(name, "active_locked_border_color") == 0)
639 snprintf(rsp, BUFSIZ, "%s (%06X)", active_locked_border_color, active_locked_border_color_pxl);
640 else if (strcmp(name, "normal_locked_border_color") == 0)
641 snprintf(rsp, BUFSIZ, "%s (%06X)", normal_locked_border_color, normal_locked_border_color_pxl);
642 else if (strcmp(name, "urgent_border_color") == 0)
643 snprintf(rsp, BUFSIZ, "%s (%06X)", urgent_border_color, urgent_border_color_pxl);
644 else if (strcmp(name, "borderless_monocle") == 0)
645 snprintf(rsp, BUFSIZ, "%s", BOOLSTR(borderless_monocle));
646 else if (strcmp(name, "gapless_monocle") == 0)
647 snprintf(rsp, BUFSIZ, "%s", BOOLSTR(gapless_monocle));
648 else if (strcmp(name, "focus_follows_pointer") == 0)
649 snprintf(rsp, BUFSIZ, "%s", BOOLSTR(focus_follows_pointer));
650 else if (strcmp(name, "pointer_follows_monitor") == 0)
651 snprintf(rsp, BUFSIZ, "%s", BOOLSTR(pointer_follows_monitor));
652 else if (strcmp(name, "adaptative_raise") == 0)
653 snprintf(rsp, BUFSIZ, "%s", BOOLSTR(adaptative_raise));
654 else if (strcmp(name, "apply_shadow_property") == 0)
655 snprintf(rsp, BUFSIZ, "%s", BOOLSTR(apply_shadow_property));
656 else if (strcmp(name, "auto_alternate") == 0)
657 snprintf(rsp, BUFSIZ, "%s", BOOLSTR(auto_alternate));
658 else if (strcmp(name, "focus_by_distance") == 0)
659 snprintf(rsp, BUFSIZ, "%s", BOOLSTR(focus_by_distance));
660 else if (strcmp(name, "wm_name") == 0)
661 snprintf(rsp, BUFSIZ, "%s", wm_name);
663 snprintf(rsp, BUFSIZ, "unknown setting: %s", name);
666 bool parse_bool(char *value, bool *b)
668 if (strcmp(value, "true") == 0) {
671 } else if (strcmp(value, "false") == 0) {
678 bool parse_layout(char *s, layout_t *l)
680 if (strcmp(s, "monocle") == 0) {
683 } else if (strcmp(s, "tiled") == 0) {
690 bool parse_direction(char *s, direction_t *d)
692 if (strcmp(s, "up") == 0) {
695 } else if (strcmp(s, "down") == 0) {
698 } else if (strcmp(s, "left") == 0) {
701 } else if (strcmp(s, "right") == 0) {
708 bool parse_nearest_argument(char *s, nearest_arg_t *a)
710 if (strcmp(s, "older") == 0) {
713 } else if (strcmp(s, "newer") == 0) {
720 bool parse_cycle_direction(char *s, cycle_dir_t *d)
722 if (strcmp(s, "prev") == 0) {
725 } else if (strcmp(s, "next") == 0) {
732 bool parse_circulate_direction(char *s, circulate_dir_t *d)
734 if (strcmp(s, "forward") == 0) {
735 *d = CIRCULATE_FORWARD;
737 } else if (strcmp(s, "backward") == 0) {
738 *d = CIRCULATE_BACKWARD;
744 bool parse_skip_client(char *s, skip_client_t *k)
747 *k = CLIENT_SKIP_NONE;
749 } else if (strcmp(s, "--skip-floating") == 0) {
750 *k = CLIENT_SKIP_FLOATING;
752 } else if (strcmp(s, "--skip-tiled") == 0) {
753 *k = CLIENT_SKIP_TILED;
755 } else if (strcmp(s, "--skip-class-equal") == 0) {
756 *k = CLIENT_SKIP_CLASS_EQUAL;
758 } else if (strcmp(s, "--skip-class-differ") == 0) {
759 *k = CLIENT_SKIP_CLASS_DIFFER;
765 bool parse_skip_desktop(char *s, skip_desktop_t *k)
768 *k = DESKTOP_SKIP_NONE;
770 } else if (strcmp(s, "--skip-free") == 0) {
771 *k = DESKTOP_SKIP_FREE;
773 } else if (strcmp(s, "--skip-occupied") == 0) {
774 *k = DESKTOP_SKIP_OCCUPIED;
780 bool parse_list_option(char *s, list_option_t *o)
783 *o = LIST_OPTION_VERBOSE;
785 } else if (strcmp(s, "--quiet") == 0) {
786 *o = LIST_OPTION_QUIET;
792 bool parse_send_option(char *s, send_option_t *o)
795 *o = SEND_OPTION_DONT_FOLLOW;
797 } else if (strcmp(s, "--follow") == 0) {
798 *o = SEND_OPTION_FOLLOW;
804 bool parse_swap_option(char *s, swap_option_t *o)
807 *o = SWAP_OPTION_SWAP_FOCUS;
809 } else if (strcmp(s, "--keep-focus") == 0) {
810 *o = SWAP_OPTION_KEEP_FOCUS;
816 bool parse_rotate(char *s, rotate_t *r)
818 if (strcmp(s, "clockwise") == 0) {
819 *r = ROTATE_CLOCKWISE;
821 } else if (strcmp(s, "counter_clockwise") == 0) {
822 *r = ROTATE_COUNTER_CLOCKWISE;
824 } else if (strcmp(s, "full_cycle") == 0) {
825 *r = ROTATE_FULL_CYCLE;
831 bool parse_flip(char *s, flip_t *f)
833 if (strcmp(s, "horizontal") == 0) {
834 *f = FLIP_HORIZONTAL;
836 } else if (strcmp(s, "vertical") == 0) {
843 bool parse_fence_move(char *s, fence_move_t *m)
845 if (strcmp(s, "push") == 0) {
848 } else if (strcmp(s, "pull") == 0) {
855 bool parse_pointer_action(char *s, pointer_action_t *a)
857 if (strcmp(s, "move") == 0) {
860 } else if (strcmp(s, "resize_corner") == 0) {
861 *a = ACTION_RESIZE_CORNER;
863 } else if (strcmp(s, "resize_side") == 0) {
864 *a = ACTION_RESIZE_SIDE;
866 } else if (strcmp(s, "focus") == 0) {