diff options
author | emersion <contact@emersion.fr> | 2018-11-19 17:56:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-19 17:56:18 +0100 |
commit | bf7af9c690de1da94a5fa258747cd983cb61b707 (patch) | |
tree | 1b731331f1ea6ebb430a9bf4dbc1db482bc7ff5d /sway | |
parent | Merge pull request #3152 from camoz/master (diff) | |
parent | Implement strip_workspace_name. (diff) | |
download | sway-bf7af9c690de1da94a5fa258747cd983cb61b707.tar.gz sway-bf7af9c690de1da94a5fa258747cd983cb61b707.tar.zst sway-bf7af9c690de1da94a5fa258747cd983cb61b707.zip |
Merge pull request #3083 from c-edw/feature/StripWorkspaceName
Implement strip_workspace_name.
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands/bar.c | 1 | ||||
-rw-r--r-- | sway/commands/bar/strip_workspace_name.c | 32 | ||||
-rw-r--r-- | sway/commands/bar/strip_workspace_numbers.c | 17 | ||||
-rw-r--r-- | sway/config/bar.c | 1 | ||||
-rw-r--r-- | sway/ipc-json.c | 2 | ||||
-rw-r--r-- | sway/meson.build | 1 | ||||
-rw-r--r-- | sway/sway-bar.5.scd | 4 |
7 files changed, 51 insertions, 7 deletions
diff --git a/sway/commands/bar.c b/sway/commands/bar.c index c808aef2..f9ed530e 100644 --- a/sway/commands/bar.c +++ b/sway/commands/bar.c | |||
@@ -25,6 +25,7 @@ static struct cmd_handler bar_handlers[] = { | |||
25 | { "secondary_button", bar_cmd_secondary_button }, | 25 | { "secondary_button", bar_cmd_secondary_button }, |
26 | { "separator_symbol", bar_cmd_separator_symbol }, | 26 | { "separator_symbol", bar_cmd_separator_symbol }, |
27 | { "status_command", bar_cmd_status_command }, | 27 | { "status_command", bar_cmd_status_command }, |
28 | { "strip_workspace_name", bar_cmd_strip_workspace_name }, | ||
28 | { "strip_workspace_numbers", bar_cmd_strip_workspace_numbers }, | 29 | { "strip_workspace_numbers", bar_cmd_strip_workspace_numbers }, |
29 | { "tray_output", bar_cmd_tray_output }, | 30 | { "tray_output", bar_cmd_tray_output }, |
30 | { "tray_padding", bar_cmd_tray_padding }, | 31 | { "tray_padding", bar_cmd_tray_padding }, |
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 | } |
diff --git a/sway/config/bar.c b/sway/config/bar.c index 7bca5f49..7009d0a0 100644 --- a/sway/config/bar.c +++ b/sway/config/bar.c | |||
@@ -100,6 +100,7 @@ struct bar_config *default_bar_config(void) { | |||
100 | bar->wrap_scroll = false; | 100 | bar->wrap_scroll = false; |
101 | bar->separator_symbol = NULL; | 101 | bar->separator_symbol = NULL; |
102 | bar->strip_workspace_numbers = false; | 102 | bar->strip_workspace_numbers = false; |
103 | bar->strip_workspace_name = false; | ||
103 | bar->binding_mode_indicator = true; | 104 | bar->binding_mode_indicator = true; |
104 | bar->verbose = false; | 105 | bar->verbose = false; |
105 | bar->pid = 0; | 106 | bar->pid = 0; |
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index e3450df1..05e453ec 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c | |||
@@ -581,6 +581,8 @@ json_object *ipc_json_describe_bar_config(struct bar_config *bar) { | |||
581 | json_object_new_boolean(bar->workspace_buttons)); | 581 | json_object_new_boolean(bar->workspace_buttons)); |
582 | json_object_object_add(json, "strip_workspace_numbers", | 582 | json_object_object_add(json, "strip_workspace_numbers", |
583 | json_object_new_boolean(bar->strip_workspace_numbers)); | 583 | json_object_new_boolean(bar->strip_workspace_numbers)); |
584 | json_object_object_add(json, "strip_workspace_name", | ||
585 | json_object_new_boolean(bar->strip_workspace_name)); | ||
584 | json_object_object_add(json, "binding_mode_indicator", | 586 | json_object_object_add(json, "binding_mode_indicator", |
585 | json_object_new_boolean(bar->binding_mode_indicator)); | 587 | json_object_new_boolean(bar->binding_mode_indicator)); |
586 | json_object_object_add(json, "verbose", | 588 | json_object_object_add(json, "verbose", |
diff --git a/sway/meson.build b/sway/meson.build index d9bc08f3..14822dbd 100644 --- a/sway/meson.build +++ b/sway/meson.build | |||
@@ -114,6 +114,7 @@ sway_sources = files( | |||
114 | 'commands/bar/separator_symbol.c', | 114 | 'commands/bar/separator_symbol.c', |
115 | 'commands/bar/status_command.c', | 115 | 'commands/bar/status_command.c', |
116 | 'commands/bar/strip_workspace_numbers.c', | 116 | 'commands/bar/strip_workspace_numbers.c', |
117 | 'commands/bar/strip_workspace_name.c', | ||
117 | 'commands/bar/swaybar_command.c', | 118 | 'commands/bar/swaybar_command.c', |
118 | 'commands/bar/tray_output.c', | 119 | 'commands/bar/tray_output.c', |
119 | 'commands/bar/tray_padding.c', | 120 | 'commands/bar/tray_padding.c', |
diff --git a/sway/sway-bar.5.scd b/sway/sway-bar.5.scd index 873741c0..60ee9999 100644 --- a/sway/sway-bar.5.scd +++ b/sway/sway-bar.5.scd | |||
@@ -50,6 +50,10 @@ Sway allows configuring swaybar in the sway configuration file. | |||
50 | *workspace\_buttons* yes|no | 50 | *workspace\_buttons* yes|no |
51 | Enables or disables workspace buttons on the bar. Default is _yes_. | 51 | Enables or disables workspace buttons on the bar. Default is _yes_. |
52 | 52 | ||
53 | *strip\_workspace\_name* yes|no | ||
54 | If set to _yes_, then workspace names will be omitted from the workspace | ||
55 | button and only the custom number will be shown. Default is _no_. | ||
56 | |||
53 | *strip\_workspace\_numbers* yes|no | 57 | *strip\_workspace\_numbers* yes|no |
54 | If set to _yes_, then workspace numbers will be omitted from the workspace | 58 | If set to _yes_, then workspace numbers will be omitted from the workspace |
55 | button and only the custom name will be shown. Default is _no_. | 59 | button and only the custom name will be shown. Default is _no_. |