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))
91 } else if (strcmp(cmd, "track_pointer") == 0) {
92 char *arg1 = strtok(NULL, TOK_SEP);
95 char *arg2 = strtok(NULL, TOK_SEP);
99 if (sscanf(arg1, "%i", &root_x) == 1 && sscanf(arg2, "%i", &root_y) == 1)
100 track_pointer(root_x, root_y);
102 } 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->focus->client);
138 } else if (strcmp(cmd, "toggle_floating") == 0) {
139 split_mode = MODE_AUTOMATIC;
140 toggle_floating(mon->desk->focus);
141 } else if (strcmp(cmd, "toggle_locked") == 0) {
142 if (mon->desk->focus != NULL)
143 toggle_locked(mon->desk->focus->client);
144 } else if (strcmp(cmd, "toggle_visibility") == 0) {
146 } else if (strcmp(cmd, "pad") == 0) {
147 char *name = strtok(NULL, TOK_SEP);
149 monitor_t *m = find_monitor(name);
151 char args[BUFSIZ] = {0}, *s;
152 while ((s = strtok(NULL, TOK_SEP)) != NULL) {
153 strncat(args, s, REMLEN(args));
154 strncat(args, TOK_SEP, REMLEN(args));
156 if (strlen(args) > 0) {
157 sscanf(args, "%i %i %i %i", &m->top_padding, &m->right_padding, &m->bottom_padding, &m->left_padding);
160 snprintf(rsp, BUFSIZ, "%i %i %i %i\n", m->top_padding, m->right_padding, m->bottom_padding, m->left_padding);
165 } else if (strcmp(cmd, "ratio") == 0) {
166 char *value = strtok(NULL, TOK_SEP);
167 if (value != NULL && mon->desk->focus != NULL)
168 sscanf(value, "%lf", &mon->desk->focus->split_ratio);
169 } else if (strcmp(cmd, "cancel") == 0) {
170 split_mode = MODE_AUTOMATIC;
171 window_draw_border(mon->desk->focus, true, true);
173 } else if (strcmp(cmd, "presel") == 0) {
174 if (mon->desk->focus == NULL || !is_tiled(mon->desk->focus->client) || mon->desk->layout != LAYOUT_TILED)
176 char *dir = strtok(NULL, TOK_SEP);
179 if (parse_direction(dir, &d)) {
180 split_mode = MODE_MANUAL;
182 char *rat = strtok(NULL, TOK_SEP);
184 sscanf(rat, "%lf", &mon->desk->focus->split_ratio);
185 window_draw_border(mon->desk->focus, true, true);
189 } else if (strcmp(cmd, "push") == 0 || strcmp(cmd, "pull") == 0) {
190 char *dir = strtok(NULL, TOK_SEP);
194 if (parse_fence_move(cmd, &m) && parse_direction(dir, &d)) {
195 move_fence(mon->desk->focus, d, m);
198 } else if (strcmp(cmd, "drop_to_monitor") == 0) {
199 char *dir = strtok(NULL, TOK_SEP);
202 if (parse_cycle_direction(dir, &d)) {
205 m = ((mon->next == NULL ? mon_head : mon->next));
207 m = ((mon->prev == NULL ? mon_tail : mon->prev));
208 transfer_node(mon, mon->desk, m, m->desk, mon->desk->focus);
210 char *opt = strtok(NULL, TOK_SEP);
212 if (parse_send_option(opt, &o) && o == SEND_OPTION_FOLLOW)
213 focus_node(m, m->desk, m->desk->focus);
216 } else if (strcmp(cmd, "send_to_monitor") == 0) {
217 char *name = strtok(NULL, TOK_SEP);
219 monitor_t *m = find_monitor(name);
220 if (m != NULL && m != mon) {
221 transfer_node(mon, mon->desk, m, m->desk, mon->desk->focus);
223 char *opt = strtok(NULL, TOK_SEP);
225 if (parse_send_option(opt, &o) && o == SEND_OPTION_FOLLOW)
226 focus_node(m, m->desk, m->desk->focus);
229 } else if (strcmp(cmd, "drop_to") == 0) {
230 char *dir = strtok(NULL, TOK_SEP);
233 if (parse_cycle_direction(dir, &c)) {
236 d = ((mon->desk->next == NULL ? mon->desk_head : mon->desk->next));
238 d = ((mon->desk->prev == NULL ? mon->desk_tail : mon->desk->prev));
239 transfer_node(mon, mon->desk, mon, d, mon->desk->focus);
240 char *opt = strtok(NULL, TOK_SEP);
242 if (parse_send_option(opt, &o) && o == SEND_OPTION_FOLLOW)
243 focus_node(mon, d, d->focus);
246 } else if (strcmp(cmd, "send_to") == 0) {
247 char *name = strtok(NULL, TOK_SEP);
249 desktop_location_t loc;
250 if (locate_desktop(name, &loc)) {
251 transfer_node(mon, mon->desk, loc.monitor, loc.desktop, mon->desk->focus);
252 if (mon != loc.monitor && loc.monitor->desk == loc.desktop)
253 arrange(loc.monitor, loc.desktop);
254 char *opt = strtok(NULL, TOK_SEP);
256 if (parse_send_option(opt, &o) && o == SEND_OPTION_FOLLOW)
257 focus_node(loc.monitor, loc.desktop, loc.desktop->focus);
260 } else if (strcmp(cmd, "rename_monitor") == 0) {
261 char *cur_name = strtok(NULL, TOK_SEP);
262 if (cur_name != NULL) {
263 monitor_t *m = find_monitor(cur_name);
265 char *new_name = strtok(NULL, TOK_SEP);
266 if (new_name != NULL) {
267 strncpy(m->name, new_name, sizeof(m->name));
272 } else if (strcmp(cmd, "rename") == 0) {
273 char *cur_name = strtok(NULL, TOK_SEP);
274 if (cur_name != NULL) {
275 desktop_location_t loc;
276 if (locate_desktop(cur_name, &loc)) {
277 char *new_name = strtok(NULL, TOK_SEP);
278 if (new_name != NULL) {
279 strncpy(loc.desktop->name, new_name, sizeof(loc.desktop->name));
280 ewmh_update_desktop_names();
285 } else if (strcmp(cmd, "use_monitor") == 0) {
286 char *name = strtok(NULL, TOK_SEP);
288 monitor_t *m = find_monitor(name);
290 if (auto_alternate && m == mon && last_mon != NULL)
291 focus_node(last_mon, last_mon->desk, last_mon->desk->focus);
293 focus_node(m, m->desk, m->desk->focus);
296 } else if (strcmp(cmd, "use") == 0) {
297 char *name = strtok(NULL, TOK_SEP);
299 desktop_location_t loc;
300 if (locate_desktop(name, &loc)) {
301 if (auto_alternate && loc.desktop == mon->desk && mon->last_desk != NULL)
302 focus_node(mon, mon->last_desk, mon->last_desk->focus);
304 focus_node(loc.monitor, loc.desktop, loc.desktop->focus);
307 } else if (strcmp(cmd, "cycle_monitor") == 0) {
308 char *dir = strtok(NULL, TOK_SEP);
311 if (parse_cycle_direction(dir, &d))
314 } else if (strcmp(cmd, "cycle_desktop") == 0) {
315 char *dir = strtok(NULL, TOK_SEP);
318 if (parse_cycle_direction(dir, &d)) {
320 char *skip = strtok(NULL, TOK_SEP);
321 if (parse_skip_desktop(skip, &k))
322 cycle_desktop(mon, mon->desk, d, k);
325 } else if (strcmp(cmd, "cycle") == 0) {
326 if (mon->desk->focus != NULL && mon->desk->focus->client->fullscreen)
328 char *dir = strtok(NULL, TOK_SEP);
331 if (parse_cycle_direction(dir, &d)) {
333 char *skip = strtok(NULL, TOK_SEP);
334 if (parse_skip_client(skip, &k))
335 cycle_leaf(mon, mon->desk, mon->desk->focus, d, k);
339 } else if (strcmp(cmd, "nearest") == 0) {
340 if (mon->desk->focus != NULL && mon->desk->focus->client->fullscreen)
342 char *arg = strtok(NULL, TOK_SEP);
345 if (parse_nearest_argument(arg, &a)) {
347 char *skip = strtok(NULL, TOK_SEP);
348 if (parse_skip_client(skip, &k))
349 nearest_leaf(mon, mon->desk, mon->desk->focus, a, k);
353 } else if (strcmp(cmd, "biggest") == 0) {
354 node_t *n = find_biggest(mon->desk);
356 snprintf(rsp, BUFSIZ, "0x%X", n->client->window);
358 } else if (strcmp(cmd, "circulate") == 0) {
359 if (mon->desk->layout == LAYOUT_MONOCLE
360 || (mon->desk->focus != NULL && !is_tiled(mon->desk->focus->client)))
362 char *dir = strtok(NULL, TOK_SEP);
365 if (parse_circulate_direction(dir, &d))
366 circulate_leaves(mon, mon->desk, d);
368 } else if (strcmp(cmd, "rule") == 0) {
369 char *name = strtok(NULL, TOK_SEP);
371 rule_t *rule = make_rule();
372 strncpy(rule->cause.name, name, sizeof(rule->cause.name));
373 char *arg = strtok(NULL, TOK_SEP);
374 while (arg != NULL) {
375 if (strcmp(arg, "floating") == 0) {
376 rule->effect.floating = true;
377 } else if (strcmp(arg, "follow") == 0) {
378 rule->effect.follow = true;
380 desktop_location_t loc;
381 if (locate_desktop(arg, &loc)) {
382 rule->effect.monitor = loc.monitor;
383 rule->effect.desktop = loc.desktop;
386 arg = strtok(NULL, TOK_SEP);
391 } else if (strcmp(cmd, "remove_rule") == 0) {
394 while ((arg = strtok(NULL, TOK_SEP)) != NULL)
395 if (sscanf(arg, "%X", &uid) > 0)
396 remove_rule_by_uid(uid);
398 } else if (strcmp(cmd, "swap") == 0) {
399 node_t *last_focus = history_get(mon->desk->history, 1);
400 swap_nodes(mon->desk->focus, last_focus);
401 char *opt = strtok(NULL, TOK_SEP);
403 if (parse_swap_option(opt, &o) && o == SWAP_OPTION_SWAP_FOCUS)
404 focus_node(mon, mon->desk, last_focus);
405 } else if (strcmp(cmd, "alternate") == 0) {
406 focus_node(mon, mon->desk, history_get(mon->desk->history, 1));
408 } else if (strcmp(cmd, "alternate_desktop") == 0) {
409 if (mon->last_desk != NULL)
410 focus_node(mon, mon->last_desk, mon->last_desk->focus);
411 } else if (strcmp(cmd, "alternate_monitor") == 0) {
412 if (last_mon != NULL)
413 focus_node(last_mon, last_mon->desk, last_mon->desk->focus);
414 } else if (strcmp(cmd, "add_in") == 0) {
415 char *name = strtok(NULL, TOK_SEP);
417 monitor_t *m = find_monitor(name);
419 for (name = strtok(NULL, TOK_SEP); name != NULL; name = strtok(NULL, TOK_SEP))
420 add_desktop(m, name);
423 } else if (strcmp(cmd, "add") == 0) {
424 for (char *name = strtok(NULL, TOK_SEP); name != NULL; name = strtok(NULL, TOK_SEP))
425 add_desktop(mon, name);
427 } else if (strcmp(cmd, "focus") == 0) {
428 if (mon->desk->focus == NULL || mon->desk->focus->client->fullscreen)
430 char *dir = strtok(NULL, TOK_SEP);
433 if (parse_direction(dir, &d)) {
435 if (focus_by_distance)
436 n = nearest_neighbor(mon->desk, mon->desk->focus, d);
438 n = find_neighbor(mon->desk->focus, d);
439 focus_node(mon, mon->desk, n);
443 } else if (strcmp(cmd, "put_status") == 0) {
446 } else if (strcmp(cmd, "adopt_orphans") == 0) {
449 } else if (strcmp(cmd, "restore_layout") == 0) {
450 char *arg = strtok(NULL, TOK_SEP);
453 } else if (strcmp(cmd, "restore_history") == 0) {
454 char *arg = strtok(NULL, TOK_SEP);
455 restore_history(arg);
457 } else if (strcmp(cmd, "quit") == 0) {
458 char *arg = strtok(NULL, TOK_SEP);
460 sscanf(arg, "%i", &exit_status);
464 snprintf(rsp, BUFSIZ, "unknown command: %s", cmd);
468 arrange(mon, mon->desk);
471 void set_setting(char *name, char *value, char *rsp)
473 if (name == NULL || value == NULL)
476 if (strcmp(name, "border_width") == 0) {
477 sscanf(value, "%u", &border_width);
478 } else if (strcmp(name, "window_gap") == 0) {
479 sscanf(value, "%i", &window_gap);
480 } else if (strcmp(name, "split_ratio") == 0) {
481 sscanf(value, "%lf", &split_ratio);
482 } else if (strcmp(name, "left_padding") == 0) {
483 sscanf(value, "%i", &mon->left_padding);
484 } else if (strcmp(name, "right_padding") == 0) {
485 sscanf(value, "%i", &mon->right_padding);
486 } else if (strcmp(name, "top_padding") == 0) {
487 sscanf(value, "%i", &mon->top_padding);
488 } else if (strcmp(name, "bottom_padding") == 0) {
489 sscanf(value, "%i", &mon->bottom_padding);
490 } else if (strcmp(name, "focused_border_color") == 0) {
491 strncpy(focused_border_color, value, sizeof(focused_border_color));
492 focused_border_color_pxl = get_color(focused_border_color);
493 } else if (strcmp(name, "active_border_color") == 0) {
494 strncpy(active_border_color, value, sizeof(active_border_color));
495 active_border_color_pxl = get_color(active_border_color);
496 } else if (strcmp(name, "normal_border_color") == 0) {
497 strncpy(normal_border_color, value, sizeof(normal_border_color));
498 normal_border_color_pxl = get_color(normal_border_color);
499 } else if (strcmp(name, "presel_border_color") == 0) {
500 strncpy(presel_border_color, value, sizeof(presel_border_color));
501 presel_border_color_pxl = get_color(presel_border_color);
502 } else if (strcmp(name, "focused_locked_border_color") == 0) {
503 strncpy(focused_locked_border_color, value, sizeof(focused_locked_border_color));
504 focused_locked_border_color_pxl = get_color(focused_locked_border_color);
505 } else if (strcmp(name, "active_locked_border_color") == 0) {
506 strncpy(active_locked_border_color, value, sizeof(active_locked_border_color));
507 active_locked_border_color_pxl = get_color(active_locked_border_color);
508 } else if (strcmp(name, "normal_locked_border_color") == 0) {
509 strncpy(normal_locked_border_color, value, sizeof(normal_locked_border_color));
510 normal_locked_border_color_pxl = get_color(normal_locked_border_color);
511 } else if (strcmp(name, "urgent_border_color") == 0) {
512 strncpy(urgent_border_color, value, sizeof(urgent_border_color));
513 urgent_border_color_pxl = get_color(urgent_border_color);
514 } else if (strcmp(name, "borderless_monocle") == 0) {
516 if (parse_bool(value, &b))
517 borderless_monocle = b;
518 } else if (strcmp(name, "gapless_monocle") == 0) {
520 if (parse_bool(value, &b))
522 } else if (strcmp(name, "focus_follows_pointer") == 0) {
524 if (parse_bool(value, &b) && b != focus_follows_pointer) {
525 uint32_t values[] = {(focus_follows_pointer ? CLIENT_EVENT_MASK : CLIENT_EVENT_MASK_FFP)};
526 for (monitor_t *m = mon_head; m != NULL; m = m->next)
527 for (desktop_t *d = m->desk_head; d != NULL; d = d->next)
528 for (node_t *n = first_extrema(d->root); n != NULL; n = next_leaf(n, d->root))
529 xcb_change_window_attributes(dpy, n->client->window, XCB_CW_EVENT_MASK, values);
530 if (focus_follows_pointer)
531 disable_motion_recorder();
533 enable_motion_recorder();
534 focus_follows_pointer = b;
537 } else if (strcmp(name, "adaptative_raise") == 0) {
539 if (parse_bool(value, &b))
540 adaptative_raise = b;
542 } else if (strcmp(name, "apply_shadow_property") == 0) {
544 if (parse_bool(value, &b))
545 apply_shadow_property = b;
547 } else if (strcmp(name, "auto_alternate") == 0) {
549 if (parse_bool(value, &b))
552 } else if (strcmp(name, "focus_by_distance") == 0) {
554 if (parse_bool(value, &b))
555 focus_by_distance = b;
557 } else if (strcmp(name, "wm_name") == 0) {
558 strncpy(wm_name, value, sizeof(wm_name));
559 ewmh_update_wm_name();
562 snprintf(rsp, BUFSIZ, "unknown setting: %s", name);
566 arrange(mon, mon->desk);
569 void get_setting(char *name, char* rsp)
574 if (strcmp(name, "border_width") == 0)
575 snprintf(rsp, BUFSIZ, "%u", border_width);
576 else if (strcmp(name, "window_gap") == 0)
577 snprintf(rsp, BUFSIZ, "%i", window_gap);
578 else if (strcmp(name, "split_ratio") == 0)
579 snprintf(rsp, BUFSIZ, "%lf", split_ratio);
580 else if (strcmp(name, "left_padding") == 0)
581 snprintf(rsp, BUFSIZ, "%i", mon->left_padding);
582 else if (strcmp(name, "right_padding") == 0)
583 snprintf(rsp, BUFSIZ, "%i", mon->right_padding);
584 else if (strcmp(name, "top_padding") == 0)
585 snprintf(rsp, BUFSIZ, "%i", mon->top_padding);
586 else if (strcmp(name, "bottom_padding") == 0)
587 snprintf(rsp, BUFSIZ, "%i", mon->bottom_padding);
588 else if (strcmp(name, "focused_border_color") == 0)
589 snprintf(rsp, BUFSIZ, "%s (%06X)", focused_border_color, focused_border_color_pxl);
590 else if (strcmp(name, "active_border_color") == 0)
591 snprintf(rsp, BUFSIZ, "%s (%06X)", active_border_color, active_border_color_pxl);
592 else if (strcmp(name, "normal_border_color") == 0)
593 snprintf(rsp, BUFSIZ, "%s (%06X)", normal_border_color, normal_border_color_pxl);
594 else if (strcmp(name, "presel_border_color") == 0)
595 snprintf(rsp, BUFSIZ, "%s (%06X)", presel_border_color, presel_border_color_pxl);
596 else if (strcmp(name, "focused_locked_border_color") == 0)
597 snprintf(rsp, BUFSIZ, "%s (%06X)", focused_locked_border_color, focused_locked_border_color_pxl);
598 else if (strcmp(name, "active_locked_border_color") == 0)
599 snprintf(rsp, BUFSIZ, "%s (%06X)", active_locked_border_color, active_locked_border_color_pxl);
600 else if (strcmp(name, "normal_locked_border_color") == 0)
601 snprintf(rsp, BUFSIZ, "%s (%06X)", normal_locked_border_color, normal_locked_border_color_pxl);
602 else if (strcmp(name, "urgent_border_color") == 0)
603 snprintf(rsp, BUFSIZ, "%s (%06X)", urgent_border_color, urgent_border_color_pxl);
604 else if (strcmp(name, "borderless_monocle") == 0)
605 snprintf(rsp, BUFSIZ, "%s", BOOLSTR(borderless_monocle));
606 else if (strcmp(name, "gapless_monocle") == 0)
607 snprintf(rsp, BUFSIZ, "%s", BOOLSTR(gapless_monocle));
608 else if (strcmp(name, "focus_follows_pointer") == 0)
609 snprintf(rsp, BUFSIZ, "%s", BOOLSTR(focus_follows_pointer));
610 else if (strcmp(name, "adaptative_raise") == 0)
611 snprintf(rsp, BUFSIZ, "%s", BOOLSTR(adaptative_raise));
612 else if (strcmp(name, "apply_shadow_property") == 0)
613 snprintf(rsp, BUFSIZ, "%s", BOOLSTR(apply_shadow_property));
614 else if (strcmp(name, "auto_alternate") == 0)
615 snprintf(rsp, BUFSIZ, "%s", BOOLSTR(auto_alternate));
616 else if (strcmp(name, "focus_by_distance") == 0)
617 snprintf(rsp, BUFSIZ, "%s", BOOLSTR(focus_by_distance));
618 else if (strcmp(name, "wm_name") == 0)
619 snprintf(rsp, BUFSIZ, "%s", wm_name);
621 snprintf(rsp, BUFSIZ, "unknown setting: %s", name);
624 bool parse_bool(char *value, bool *b)
626 if (strcmp(value, "true") == 0) {
629 } else if (strcmp(value, "false") == 0) {
636 bool parse_layout(char *s, layout_t *l)
638 if (strcmp(s, "monocle") == 0) {
641 } else if (strcmp(s, "tiled") == 0) {
648 bool parse_direction(char *s, direction_t *d)
650 if (strcmp(s, "up") == 0) {
653 } else if (strcmp(s, "down") == 0) {
656 } else if (strcmp(s, "left") == 0) {
659 } else if (strcmp(s, "right") == 0) {
666 bool parse_nearest_argument(char *s, nearest_arg_t *a)
668 if (strcmp(s, "older") == 0) {
671 } else if (strcmp(s, "newer") == 0) {
678 bool parse_cycle_direction(char *s, cycle_dir_t *d)
680 if (strcmp(s, "prev") == 0) {
683 } else if (strcmp(s, "next") == 0) {
690 bool parse_circulate_direction(char *s, circulate_dir_t *d)
692 if (strcmp(s, "forward") == 0) {
693 *d = CIRCULATE_FORWARD;
695 } else if (strcmp(s, "backward") == 0) {
696 *d = CIRCULATE_BACKWARD;
702 bool parse_skip_client(char *s, skip_client_t *k)
705 *k = CLIENT_SKIP_NONE;
707 } else if (strcmp(s, "--skip-floating") == 0) {
708 *k = CLIENT_SKIP_FLOATING;
710 } else if (strcmp(s, "--skip-tiled") == 0) {
711 *k = CLIENT_SKIP_TILED;
713 } else if (strcmp(s, "--skip-class-equal") == 0) {
714 *k = CLIENT_SKIP_CLASS_EQUAL;
716 } else if (strcmp(s, "--skip-class-differ") == 0) {
717 *k = CLIENT_SKIP_CLASS_DIFFER;
723 bool parse_skip_desktop(char *s, skip_desktop_t *k)
726 *k = DESKTOP_SKIP_NONE;
728 } else if (strcmp(s, "--skip-free") == 0) {
729 *k = DESKTOP_SKIP_FREE;
731 } else if (strcmp(s, "--skip-occupied") == 0) {
732 *k = DESKTOP_SKIP_OCCUPIED;
738 bool parse_list_option(char *s, list_option_t *o)
740 if (s == NULL || strcmp(s, "--verbose") == 0) {
741 *o = LIST_OPTION_VERBOSE;
743 } else if (strcmp(s, "--quiet") == 0) {
744 *o = LIST_OPTION_QUIET;
750 bool parse_send_option(char *s, send_option_t *o)
753 *o = SEND_OPTION_DONT_FOLLOW;
755 } else if (strcmp(s, "--follow") == 0) {
756 *o = SEND_OPTION_FOLLOW;
762 bool parse_swap_option(char *s, swap_option_t *o)
764 if (s == NULL || strcmp(s, "--swap-focus") == 0) {
765 *o = SWAP_OPTION_SWAP_FOCUS;
767 } else if (strcmp(s, "--keep-focus") == 0) {
768 *o = SWAP_OPTION_KEEP_FOCUS;
774 bool parse_rotate(char *s, rotate_t *r)
776 if (strcmp(s, "clockwise") == 0) {
777 *r = ROTATE_CLOCKWISE;
779 } else if (strcmp(s, "counter_clockwise") == 0) {
780 *r = ROTATE_COUNTER_CLOCKWISE;
782 } else if (strcmp(s, "full_cycle") == 0) {
783 *r = ROTATE_FULL_CYCLE;
789 bool parse_flip(char *s, flip_t *f)
791 if (strcmp(s, "horizontal") == 0) {
792 *f = FLIP_HORIZONTAL;
794 } else if (strcmp(s, "vertical") == 0) {
801 bool parse_fence_move(char *s, fence_move_t *m)
803 if (strcmp(s, "push") == 0) {
806 } else if (strcmp(s, "pull") == 0) {
813 bool parse_pointer_action(char *s, pointer_action_t *a)
815 if (strcmp(s, "move") == 0) {
818 } else if (strcmp(s, "resize_corner") == 0) {
819 *a = ACTION_RESIZE_CORNER;
821 } else if (strcmp(s, "resize_side") == 0) {
822 *a = ACTION_RESIZE_SIDE;
824 } else if (strcmp(s, "focus") == 0) {