aboutsummaryrefslogtreecommitdiff
path: root/sway/commands
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands')
-rw-r--r--sway/commands/bar.c1
-rw-r--r--sway/commands/bar/workspace_min_width.c33
2 files changed, 34 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);
+}