summaryrefslogtreecommitdiffstats
path: root/sway/commands.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands.c')
-rw-r--r--sway/commands.c60
1 files changed, 37 insertions, 23 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 5035316e..444e6159 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -410,37 +410,51 @@ static bool cmd_fullscreen(struct sway_config *config, int argc, char **argv) {
410} 410}
411 411
412static bool cmd_workspace(struct sway_config *config, int argc, char **argv) { 412static bool cmd_workspace(struct sway_config *config, int argc, char **argv) {
413 if (!checkarg(argc, "workspace", EXPECTED_EQUAL_TO, 1)) { 413 if (!checkarg(argc, "workspace", EXPECTED_AT_LEAST, 1)) {
414 return false; 414 return false;
415 } 415 }
416 416
417 // Handle workspace next/prev 417 if (argc == 1) {
418 if (strcmp(argv[0], "next") == 0) { 418 // Handle workspace next/prev
419 workspace_next(); 419 if (strcmp(argv[0], "next") == 0) {
420 return true; 420 workspace_next();
421 } 421 return true;
422 }
422 423
423 if (strcmp(argv[0], "prev") == 0) { 424 if (strcmp(argv[0], "prev") == 0) {
424 workspace_next(); 425 workspace_next();
425 return true; 426 return true;
426 } 427 }
427 428
428 // Handle workspace output_next/prev 429 // Handle workspace output_next/prev
429 if (strcmp(argv[0], "next_on_output") == 0) { 430 if (strcmp(argv[0], "next_on_output") == 0) {
430 workspace_output_next(); 431 workspace_output_next();
431 return true; 432 return true;
432 } 433 }
433 434
434 if (strcmp(argv[0], "prev_on_output") == 0) { 435 if (strcmp(argv[0], "prev_on_output") == 0) {
435 workspace_output_prev(); 436 workspace_output_prev();
436 return true; 437 return true;
437 } 438 }
438 439
439 swayc_t *workspace = workspace_find_by_name(argv[0]); 440 swayc_t *workspace = workspace_find_by_name(argv[0]);
440 if (!workspace) { 441 if (!workspace) {
441 workspace = workspace_create(argv[0]); 442 workspace = workspace_create(argv[0]);
443 }
444 workspace_switch(workspace);
445 } else {
446 if (strcasecmp(argv[1], "output") == 0) {
447 if (!checkarg(argc, "workspace", EXPECTED_EQUAL_TO, 3)) {
448 return false;
449 }
450 struct workspace_output *wso = calloc(1, sizeof(struct workspace_output));
451 sway_log(L_DEBUG, "Assigning workspace %s to output %s", argv[0], argv[2]);
452 wso->workspace = strdup(argv[0]);
453 wso->output = strdup(argv[2]);
454 list_add(config->workspace_outputs, wso);
455 // TODO: Consider moving any existing workspace to that output? This might be executed sometime after config load
456 }
442 } 457 }
443 workspace_switch(workspace);
444 return true; 458 return true;
445} 459}
446 460