aboutsummaryrefslogtreecommitdiff
path: root/sway/commands/workspace.c
diff options
context:
space:
mode:
authorRyan Dwyer <ryandwyer1@gmail.com>2016-09-25 21:42:28 +1000
committerRyan Dwyer <ryandwyer1@gmail.com>2016-09-25 21:42:28 +1000
commit64d463142f4103b3ef94856ce4366e7f94c82034 (patch)
tree77e3b390015a4686ec72891a9abe4bfe46a5f42d /sway/commands/workspace.c
parentd98c26d0edbab66042ff3da0348d339fd857f99d (diff)
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 @@
#include "sway/workspace.h"
#include "list.h"
#include "log.h"
+#include "stringop.h"
struct cmd_results *cmd_workspace(int argc, char **argv) {
struct cmd_results *error = NULL;
if ((error = checkarg(argc, "workspace", EXPECTED_AT_LEAST, 1))) {
return error;
}
- if (argc == 1 || (argc == 2 && strcasecmp(argv[0], "number") == 0) ) {
+ if (argc == 1 || (argc >= 2 && strcasecmp(argv[0], "number") == 0) ) {
if (config->reading || !config->active) {
return cmd_results_new(CMD_DEFER, "workspace", NULL);
}
- // Handle workspace next/prev
swayc_t *ws = NULL;
- if (argc == 2) {
+ if (argc >= 2) {
if (!(ws = workspace_by_number(argv[1]))) {
- ws = workspace_create(argv[1]);
+ char *name = join_args(argv + 1, argc - 1);
+ ws = workspace_create(name);
+ free(name);
}
} else if (strcasecmp(argv[0], "next") == 0) {
ws = workspace_next();