aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/workspace.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/workspace.c')
-rw-r--r--sway/commands/workspace.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/sway/commands/workspace.c b/sway/commands/workspace.c
index 2ce7872d..63f29641 100644
--- a/sway/commands/workspace.c
+++ b/sway/commands/workspace.c
@@ -20,6 +20,8 @@ static struct workspace_config *workspace_config_find_or_create(char *ws_name) {
20 return NULL; 20 return NULL;
21 } 21 }
22 wsc->workspace = strdup(ws_name); 22 wsc->workspace = strdup(ws_name);
23 wsc->gaps_inner = -1;
24 wsc->gaps_outer = -1;
23 list_add(config->workspace_configs, wsc); 25 list_add(config->workspace_configs, wsc);
24 return wsc; 26 return wsc;
25} 27}
@@ -37,6 +39,7 @@ struct cmd_results *cmd_workspace(int argc, char **argv) {
37 } 39 }
38 40
39 int output_location = -1; 41 int output_location = -1;
42 int gaps_location = -1;
40 43
41 for (int i = 0; i < argc; ++i) { 44 for (int i = 0; i < argc; ++i) {
42 if (strcasecmp(argv[i], "output") == 0) { 45 if (strcasecmp(argv[i], "output") == 0) {
@@ -44,6 +47,12 @@ struct cmd_results *cmd_workspace(int argc, char **argv) {
44 break; 47 break;
45 } 48 }
46 } 49 }
50 for (int i = 0; i < argc; ++i) {
51 if (strcasecmp(argv[i], "gaps") == 0) {
52 gaps_location = i;
53 break;
54 }
55 }
47 if (output_location >= 0) { 56 if (output_location >= 0) {
48 if ((error = checkarg(argc, "workspace", EXPECTED_EQUAL_TO, output_location + 2))) { 57 if ((error = checkarg(argc, "workspace", EXPECTED_EQUAL_TO, output_location + 2))) {
49 return error; 58 return error;
@@ -57,6 +66,35 @@ struct cmd_results *cmd_workspace(int argc, char **argv) {
57 } 66 }
58 free(wsc->output); 67 free(wsc->output);
59 wsc->output = strdup(argv[output_location + 1]); 68 wsc->output = strdup(argv[output_location + 1]);
69 } else if (gaps_location >= 0) {
70 if ((error = checkarg(argc, "workspace", EXPECTED_EQUAL_TO, gaps_location + 3))) {
71 return error;
72 }
73 char *ws_name = join_args(argv, argc - 3);
74 struct workspace_config *wsc = workspace_config_find_or_create(ws_name);
75 free(ws_name);
76 if (!wsc) {
77 return cmd_results_new(CMD_FAILURE, "workspace gaps",
78 "Unable to allocate workspace output");
79 }
80 int *prop = NULL;
81 if (strcasecmp(argv[gaps_location + 1], "inner") == 0) {
82 prop = &wsc->gaps_inner;
83 } else if (strcasecmp(argv[gaps_location + 1], "outer") == 0) {
84 prop = &wsc->gaps_outer;
85 } else {
86 return cmd_results_new(CMD_FAILURE, "workspace gaps",
87 "Expected 'workspace <ws> gaps inner|outer <px>'");
88 }
89 char *end;
90 int val = strtol(argv[gaps_location + 2], &end, 10);
91
92 if (strlen(end)) {
93 free(end);
94 return cmd_results_new(CMD_FAILURE, "workspace gaps",
95 "Expected 'workspace <ws> gaps inner|outer <px>'");
96 }
97 *prop = val >= 0 ? val : 0;
60 } else { 98 } else {
61 if (config->reading || !config->active) { 99 if (config->reading || !config->active) {
62 return cmd_results_new(CMD_DEFER, "workspace", NULL); 100 return cmd_results_new(CMD_DEFER, "workspace", NULL);