aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Connor E <38229097+c-edw@users.noreply.github.com>2018-11-17 16:11:28 +0000
committerLibravatar Connor E <38229097+c-edw@users.noreply.github.com>2018-11-17 16:11:28 +0000
commit4bd46fb079fb5a32ee6eb2b297de273b261a9c71 (patch)
tree81dfd95a863ae17de78a6c69a14dd5698c6de862 /sway
parentMerge pull request #3046 from tokyovigilante/relative-transform (diff)
downloadsway-4bd46fb079fb5a32ee6eb2b297de273b261a9c71.tar.gz
sway-4bd46fb079fb5a32ee6eb2b297de273b261a9c71.tar.zst
sway-4bd46fb079fb5a32ee6eb2b297de273b261a9c71.zip
Implement strip_workspace_name.
Diffstat (limited to 'sway')
-rw-r--r--sway/commands/bar.c1
-rw-r--r--sway/commands/bar/strip_workspace_name.c32
-rw-r--r--sway/commands/bar/strip_workspace_numbers.c17
-rw-r--r--sway/config/bar.c1
-rw-r--r--sway/ipc-json.c2
-rw-r--r--sway/meson.build1
-rw-r--r--sway/sway-bar.5.scd4
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
7struct 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
6struct cmd_results *bar_cmd_strip_workspace_numbers(int argc, char **argv) { 7struct 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 8b88642e..94405a92 100644
--- a/sway/config/bar.c
+++ b/sway/config/bar.c
@@ -99,6 +99,7 @@ struct bar_config *default_bar_config(void) {
99 bar->wrap_scroll = false; 99 bar->wrap_scroll = false;
100 bar->separator_symbol = NULL; 100 bar->separator_symbol = NULL;
101 bar->strip_workspace_numbers = false; 101 bar->strip_workspace_numbers = false;
102 bar->strip_workspace_name = false;
102 bar->binding_mode_indicator = true; 103 bar->binding_mode_indicator = true;
103 bar->verbose = false; 104 bar->verbose = false;
104 bar->pid = 0; 105 bar->pid = 0;
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index 4583558c..cf1b42a6 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -559,6 +559,8 @@ json_object *ipc_json_describe_bar_config(struct bar_config *bar) {
559 json_object_new_boolean(bar->workspace_buttons)); 559 json_object_new_boolean(bar->workspace_buttons));
560 json_object_object_add(json, "strip_workspace_numbers", 560 json_object_object_add(json, "strip_workspace_numbers",
561 json_object_new_boolean(bar->strip_workspace_numbers)); 561 json_object_new_boolean(bar->strip_workspace_numbers));
562 json_object_object_add(json, "strip_workspace_name",
563 json_object_new_boolean(bar->strip_workspace_name));
562 json_object_object_add(json, "binding_mode_indicator", 564 json_object_object_add(json, "binding_mode_indicator",
563 json_object_new_boolean(bar->binding_mode_indicator)); 565 json_object_new_boolean(bar->binding_mode_indicator));
564 json_object_object_add(json, "verbose", 566 json_object_object_add(json, "verbose",
diff --git a/sway/meson.build b/sway/meson.build
index cde09a02..debd7a91 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_.