aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authorTarmack <git@tarmack.eu>2020-10-03 15:45:26 +0200
committerSimon Ser <contact@emersion.fr>2020-10-11 19:12:42 +0200
commit989123a2a5933367e5c7c39c3793f4814e026bf1 (patch)
tree8a13986177a3380b3d3c965ceb2526e6ceb9c88d /sway
parent657587964e5d8e444ac64829a0aab309c25ff50f (diff)
Add support for workspace_min_width bar option.
Diffstat (limited to 'sway')
-rw-r--r--sway/commands/bar.c1
-rw-r--r--sway/commands/bar/workspace_min_width.c33
-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.scd5
-rw-r--r--sway/sway-ipc.7.scd4
7 files changed, 47 insertions, 0 deletions
diff --git a/sway/commands/bar.c b/sway/commands/bar.c
index 7370910d..d42b7fc2 100644
--- a/sway/commands/bar.c
+++ b/sway/commands/bar.c
@@ -36,6 +36,7 @@ static struct cmd_handler bar_handlers[] = {
{ "unbindcode", bar_cmd_unbindcode },
{ "unbindsym", bar_cmd_unbindsym },
{ "workspace_buttons", bar_cmd_workspace_buttons },
+ { "workspace_min_width", bar_cmd_workspace_min_width },
{ "wrap_scroll", bar_cmd_wrap_scroll },
};
diff --git a/sway/commands/bar/workspace_min_width.c b/sway/commands/bar/workspace_min_width.c
new file mode 100644
index 00000000..8d65592c
--- /dev/null
+++ b/sway/commands/bar/workspace_min_width.c
@@ -0,0 +1,33 @@
+#include <stdlib.h>
+#include <strings.h>
+#include "config.h"
+#include "sway/commands.h"
+#include "sway/config.h"
+#include "log.h"
+
+struct cmd_results *bar_cmd_workspace_min_width(int argc, char **argv) {
+ struct cmd_results *error = NULL;
+ if ((error = checkarg(argc, "workspace_min_width", EXPECTED_AT_LEAST, 1))) {
+ return error;
+ }
+
+ struct bar_config *bar = config->current_bar;
+
+ char *end;
+ int min_width = strtol(argv[0], &end, 10);
+ if (min_width < 0 || (*end != '\0' && strcasecmp(end, "px") != 0)) {
+ return cmd_results_new(CMD_INVALID,
+ "[Bar %s] Invalid minimum workspace button width value: %s",
+ bar->id, argv[0]);
+ }
+
+ if (argc == 2 && strcasecmp(argv[1], "px") != 0) {
+ return cmd_results_new(CMD_INVALID,
+ "Expected 'workspace_min_width <px> [px]'");
+ }
+
+ sway_log(SWAY_DEBUG, "[Bar %s] Setting minimum workspace button width to %d",
+ bar->id, min_width);
+ config->current_bar->workspace_min_width = min_width;
+ return cmd_results_new(CMD_SUCCESS, NULL);
+}
diff --git a/sway/config/bar.c b/sway/config/bar.c
index 1c7c13b2..767534a6 100644
--- a/sway/config/bar.c
+++ b/sway/config/bar.c
@@ -105,6 +105,7 @@ struct bar_config *default_bar_config(void) {
bar->modifier = get_modifier_mask_by_name("Mod4");
bar->status_padding = 1;
bar->status_edge_padding = 3;
+ bar->workspace_min_width = 0;
if (!(bar->mode = strdup("dock"))) {
goto cleanup;
}
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index 9330de09..fceee84d 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -1102,6 +1102,8 @@ json_object *ipc_json_describe_bar_config(struct bar_config *bar) {
json_object_new_boolean(bar->strip_workspace_numbers));
json_object_object_add(json, "strip_workspace_name",
json_object_new_boolean(bar->strip_workspace_name));
+ json_object_object_add(json, "workspace_min_width",
+ json_object_new_int(bar->workspace_min_width));
json_object_object_add(json, "binding_mode_indicator",
json_object_new_boolean(bar->binding_mode_indicator));
json_object_object_add(json, "verbose",
diff --git a/sway/meson.build b/sway/meson.build
index 0db45836..b65a5211 100644
--- a/sway/meson.build
+++ b/sway/meson.build
@@ -144,6 +144,7 @@ sway_sources = files(
'commands/bar/tray_output.c',
'commands/bar/tray_padding.c',
'commands/bar/workspace_buttons.c',
+ 'commands/bar/workspace_min_width.c',
'commands/bar/wrap_scroll.c',
'commands/input/accel_profile.c',
diff --git a/sway/sway-bar.5.scd b/sway/sway-bar.5.scd
index 78124c92..80d08449 100644
--- a/sway/sway-bar.5.scd
+++ b/sway/sway-bar.5.scd
@@ -138,6 +138,11 @@ runtime.
*workspace_buttons* yes|no
Enables or disables workspace buttons on the bar. Default is _yes_.
+*workspace_min_width* <px> [px]
+ Specifies the minimum width for the workspace buttons on the bar. Default is _0_.
+
+ This setting also applies to the current binding mode indicator.
+
## TRAY
Swaybar provides a system tray where third-party applications may place icons.
diff --git a/sway/sway-ipc.7.scd b/sway/sway-ipc.7.scd
index 495e2e7d..018080fe 100644
--- a/sway/sway-ipc.7.scd
+++ b/sway/sway-ipc.7.scd
@@ -829,6 +829,9 @@ their value mean can be found in *sway-bar*(5):
|- workspace_buttons
: boolean
: Whether to display the workspace buttons on the bar
+|- workspace_min_width
+: integer
+: Minimum width in px for the workspace buttons on the bar
|- binding_mode_indicator
: boolean
: Whether to display the current binding mode on the bar
@@ -931,6 +934,7 @@ containing the _#RRGGBBAA_ representation of the color:
"status_padding": 1,
"status_edge_padding": 3,
"workspace_buttons": true,
+ "workspace_min_width": 0,
"binding_mode_indicator": true,
"verbose": false,
"pango_markup": false,