- char *cmd = strtok(msg, TOK_SEP);
-
- if (cmd == NULL)
- return;
-
- if (strcmp(cmd, "get") == 0) {
- char *name = strtok(NULL, TOK_SEP);
- get_setting(name, rsp);
- return;
- } else if (strcmp(cmd, "set") == 0) {
- char *name = strtok(NULL, TOK_SEP);
- char *value = strtok(NULL, TOK_SEP);
- set_setting(name, value, rsp);
- return;
- } else if (strcmp(cmd, "list") == 0) {
- char *name = strtok(NULL, TOK_SEP);
- if (name != NULL) {
- desktop_location_t loc;
- if (locate_desktop(name, &loc))
- list(loc.desktop, loc.desktop->root, rsp, 0);
- } else {
- list(mon->desk, mon->desk->root, rsp, 0);
- }
- return;
- } else if (strcmp(cmd, "list_monitors") == 0) {
- char *arg = strtok(NULL, TOK_SEP);
- list_option_t opt;
- if (parse_list_option(arg, &opt))
- list_monitors(opt, rsp);
- return;
- } else if (strcmp(cmd, "list_desktops") == 0) {
- char *arg = strtok(NULL, TOK_SEP);
- list_option_t opt;
- if (parse_list_option(arg, &opt))
- list_desktops(mon, opt, 0, rsp);
- return;
- } else if (strcmp(cmd, "list_windows") == 0) {
- list_windows(rsp);
- return;
- } else if (strcmp(cmd, "list_history") == 0) {
- char *name = strtok(NULL, TOK_SEP);
- if (name != NULL) {
- desktop_location_t loc;
- if (locate_desktop(name, &loc))
- list_history(loc.desktop, rsp);
- } else {
- list_history(mon->desk, rsp);
- }
- return;
- } else if (strcmp(cmd, "list_rules") == 0) {
- list_rules(rsp);
- return;
- } else if (strcmp(cmd, "close") == 0) {
- window_close(mon->desk->focus);
- return;
- } else if (strcmp(cmd, "kill") == 0) {
- window_kill(mon->desk, mon->desk->focus);
- } else if (strcmp(cmd, "rotate") == 0) {
- char *deg = strtok(NULL, TOK_SEP);
- if (deg != NULL) {
- rotate_t r;
- if (parse_rotate(deg, &r))
- rotate_tree(mon->desk->root, r);
- }
- } else if (strcmp(cmd, "flip") == 0) {
- char *flp = strtok(NULL, TOK_SEP);
- if (flp != NULL) {
- flip_t f;
- if (parse_flip(flp, &f))
- flip_tree(mon->desk->root, f);
- }
- } else if (strcmp(cmd, "balance") == 0) {
- balance_tree(mon->desk->root);
- } else if (strcmp(cmd, "grab_pointer") == 0) {
- char *pac = strtok(NULL, TOK_SEP);
- if (pac != NULL) {
- pointer_action_t a;
- if (parse_pointer_action(pac, &a))
- grab_pointer(a);
- }
- } else if (strcmp(cmd, "track_pointer") == 0) {
- char *arg1 = strtok(NULL, TOK_SEP);
- if (arg1 == NULL)
- return;
- char *arg2 = strtok(NULL, TOK_SEP);
- if (arg2 == NULL)
- return;
- int root_x, root_y;
- if (sscanf(arg1, "%i", &root_x) == 1 && sscanf(arg2, "%i", &root_y) == 1)
- track_pointer(root_x, root_y);
- return;
- } else if (strcmp(cmd, "ungrab_pointer") == 0) {
- ungrab_pointer();
- } else if (strcmp(cmd, "layout") == 0) {
- char *lyt = strtok(NULL, TOK_SEP);
- if (lyt != NULL) {
- layout_t y;
- if (parse_layout(lyt, &y)) {
- char *name = strtok(NULL, TOK_SEP);
- if (name == NULL) {
- mon->desk->layout = y;
- } else {
- desktop_location_t loc;
- do {
- if (locate_desktop(name, &loc))
- loc.desktop->layout = y;
- } while ((name = strtok(NULL, TOK_SEP)) != NULL);
- }
- }
- }
- put_status();
- } else if (strcmp(cmd, "cycle_layout") == 0) {
- if (mon->desk->layout == LAYOUT_MONOCLE)
- mon->desk->layout = LAYOUT_TILED;