diff options
author | Connor E <38229097+c-edw@users.noreply.github.com> | 2018-11-17 16:11:28 +0000 |
---|---|---|
committer | Connor E <38229097+c-edw@users.noreply.github.com> | 2018-11-17 16:11:28 +0000 |
commit | 4bd46fb079fb5a32ee6eb2b297de273b261a9c71 (patch) | |
tree | 81dfd95a863ae17de78a6c69a14dd5698c6de862 /sway/commands/bar | |
parent | Merge pull request #3046 from tokyovigilante/relative-transform (diff) | |
download | sway-4bd46fb079fb5a32ee6eb2b297de273b261a9c71.tar.gz sway-4bd46fb079fb5a32ee6eb2b297de273b261a9c71.tar.zst sway-4bd46fb079fb5a32ee6eb2b297de273b261a9c71.zip |
Implement strip_workspace_name.
Diffstat (limited to 'sway/commands/bar')
-rw-r--r-- | sway/commands/bar/strip_workspace_name.c | 32 | ||||
-rw-r--r-- | sway/commands/bar/strip_workspace_numbers.c | 17 |
2 files changed, 42 insertions, 7 deletions
diff --git a/sway/commands/bar/strip_workspace_name.c b/sway/commands/bar/strip_workspace_name.c new file mode 100644 index 00000000..79692f6e --- /dev/null +++ b/sway/commands/bar/strip_workspace_name.c | |||
@@ -0,0 +1,32 @@ | |||
1 | #include <string.h> | ||
2 | #include <strings.h> | ||
3 | #include "sway/commands.h" | ||
4 | #include "log.h" | ||
5 | #include "util.h" | ||
6 | |||
7 | struct cmd_results *bar_cmd_strip_workspace_name(int argc, char **argv) { | ||
8 | struct cmd_results *error = NULL; | ||
9 | if ((error = checkarg(argc, | ||
10 | "strip_workspace_name", EXPECTED_EQUAL_TO, 1))) { | ||
11 | return error; | ||
12 | } | ||
13 | if (!config->current_bar) { | ||
14 | return cmd_results_new(CMD_FAILURE, | ||
15 | "strip_workspace_name", "No bar defined."); | ||
16 | } | ||
17 | |||
18 | config->current_bar->strip_workspace_name = | ||
19 | parse_boolean(argv[0], config->current_bar->strip_workspace_name); | ||
20 | |||
21 | if (config->current_bar->strip_workspace_name) { | ||
22 | config->current_bar->strip_workspace_numbers = false; | ||
23 | |||
24 | wlr_log(WLR_DEBUG, "Stripping workspace name on bar: %s", | ||
25 | config->current_bar->id); | ||
26 | } else { | ||
27 | wlr_log(WLR_DEBUG, "Enabling workspace name on bar: %s", | ||
28 | config->current_bar->id); | ||
29 | } | ||
30 | |||
31 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
32 | } | ||
diff --git a/sway/commands/bar/strip_workspace_numbers.c b/sway/commands/bar/strip_workspace_numbers.c index 4e47d047..b33d01e5 100644 --- a/sway/commands/bar/strip_workspace_numbers.c +++ b/sway/commands/bar/strip_workspace_numbers.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include <strings.h> | 2 | #include <strings.h> |
3 | #include "sway/commands.h" | 3 | #include "sway/commands.h" |
4 | #include "log.h" | 4 | #include "log.h" |
5 | #include "util.h" | ||
5 | 6 | ||
6 | struct cmd_results *bar_cmd_strip_workspace_numbers(int argc, char **argv) { | 7 | struct cmd_results *bar_cmd_strip_workspace_numbers(int argc, char **argv) { |
7 | struct cmd_results *error = NULL; | 8 | struct cmd_results *error = NULL; |
@@ -13,17 +14,19 @@ struct cmd_results *bar_cmd_strip_workspace_numbers(int argc, char **argv) { | |||
13 | return cmd_results_new(CMD_FAILURE, | 14 | return cmd_results_new(CMD_FAILURE, |
14 | "strip_workspace_numbers", "No bar defined."); | 15 | "strip_workspace_numbers", "No bar defined."); |
15 | } | 16 | } |
16 | if (strcasecmp("yes", argv[0]) == 0) { | 17 | |
17 | config->current_bar->strip_workspace_numbers = true; | 18 | config->current_bar->strip_workspace_numbers = |
19 | parse_boolean(argv[0], config->current_bar->strip_workspace_numbers); | ||
20 | |||
21 | if (config->current_bar->strip_workspace_numbers) { | ||
22 | config->current_bar->strip_workspace_name = false; | ||
23 | |||
18 | wlr_log(WLR_DEBUG, "Stripping workspace numbers on bar: %s", | 24 | wlr_log(WLR_DEBUG, "Stripping workspace numbers on bar: %s", |
19 | config->current_bar->id); | 25 | config->current_bar->id); |
20 | } else if (strcasecmp("no", argv[0]) == 0) { | 26 | } else { |
21 | config->current_bar->strip_workspace_numbers = false; | ||
22 | wlr_log(WLR_DEBUG, "Enabling workspace numbers on bar: %s", | 27 | wlr_log(WLR_DEBUG, "Enabling workspace numbers on bar: %s", |
23 | config->current_bar->id); | 28 | config->current_bar->id); |
24 | } else { | ||
25 | return cmd_results_new(CMD_INVALID, | ||
26 | "strip_workspace_numbers", "Invalid value %s", argv[0]); | ||
27 | } | 29 | } |
30 | |||
28 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 31 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
29 | } | 32 | } |