aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/workspace.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2016-09-25 21:42:28 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2016-09-25 21:42:28 +1000
commit64d463142f4103b3ef94856ce4366e7f94c82034 (patch)
tree77e3b390015a4686ec72891a9abe4bfe46a5f42d /sway/commands/workspace.c
parentMerge pull request #909 from zandrmartin/grab-focused (diff)
downloadsway-64d463142f4103b3ef94856ce4366e7f94c82034.tar.gz
sway-64d463142f4103b3ef94856ce4366e7f94c82034.tar.zst
sway-64d463142f4103b3ef94856ce4366e7f94c82034.zip
Implement default name for workspace command
This implements commands such as: workspace number 9: test If a workspace with the given number exists then it will be focused, otherwise a new workspace with the given name will be created.
Diffstat (limited to 'sway/commands/workspace.c')
-rw-r--r--sway/commands/workspace.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/sway/commands/workspace.c b/sway/commands/workspace.c
index 5d4d3d65..35224f8a 100644
--- a/sway/commands/workspace.c
+++ b/sway/commands/workspace.c
@@ -5,21 +5,23 @@
5#include "sway/workspace.h" 5#include "sway/workspace.h"
6#include "list.h" 6#include "list.h"
7#include "log.h" 7#include "log.h"
8#include "stringop.h"
8 9
9struct cmd_results *cmd_workspace(int argc, char **argv) { 10struct cmd_results *cmd_workspace(int argc, char **argv) {
10 struct cmd_results *error = NULL; 11 struct cmd_results *error = NULL;
11 if ((error = checkarg(argc, "workspace", EXPECTED_AT_LEAST, 1))) { 12 if ((error = checkarg(argc, "workspace", EXPECTED_AT_LEAST, 1))) {
12 return error; 13 return error;
13 } 14 }
14 if (argc == 1 || (argc == 2 && strcasecmp(argv[0], "number") == 0) ) { 15 if (argc == 1 || (argc >= 2 && strcasecmp(argv[0], "number") == 0) ) {
15 if (config->reading || !config->active) { 16 if (config->reading || !config->active) {
16 return cmd_results_new(CMD_DEFER, "workspace", NULL); 17 return cmd_results_new(CMD_DEFER, "workspace", NULL);
17 } 18 }
18 // Handle workspace next/prev
19 swayc_t *ws = NULL; 19 swayc_t *ws = NULL;
20 if (argc == 2) { 20 if (argc >= 2) {
21 if (!(ws = workspace_by_number(argv[1]))) { 21 if (!(ws = workspace_by_number(argv[1]))) {
22 ws = workspace_create(argv[1]); 22 char *name = join_args(argv + 1, argc - 1);
23 ws = workspace_create(name);
24 free(name);
23 } 25 }
24 } else if (strcasecmp(argv[0], "next") == 0) { 26 } else if (strcasecmp(argv[0], "next") == 0) {
25 ws = workspace_next(); 27 ws = workspace_next();