summaryrefslogtreecommitdiffstats
path: root/sway/commands/bar/position.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/bar/position.c')
-rw-r--r--sway/commands/bar/position.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/sway/commands/bar/position.c b/sway/commands/bar/position.c
index 50de58e2..9c580483 100644
--- a/sway/commands/bar/position.c
+++ b/sway/commands/bar/position.c
@@ -1,3 +1,4 @@
1#define _POSIX_C_SOURCE 200809L
1#include <string.h> 2#include <string.h>
2#include <strings.h> 3#include <strings.h>
3#include "sway/commands.h" 4#include "sway/commands.h"
@@ -8,26 +9,18 @@ struct cmd_results *bar_cmd_position(int argc, char **argv) {
8 if ((error = checkarg(argc, "position", EXPECTED_EQUAL_TO, 1))) { 9 if ((error = checkarg(argc, "position", EXPECTED_EQUAL_TO, 1))) {
9 return error; 10 return error;
10 } 11 }
11
12 if (!config->current_bar) { 12 if (!config->current_bar) {
13 return cmd_results_new(CMD_FAILURE, "position", "No bar defined."); 13 return cmd_results_new(CMD_FAILURE, "position", "No bar defined.");
14 } 14 }
15 15 char *valid[] = { "top", "bottom", "left", "right" };
16 if (strcasecmp("top", argv[0]) == 0) { 16 for (size_t i = 0; i < sizeof(valid) / sizeof(valid[0]); ++i) {
17 config->current_bar->position = DESKTOP_SHELL_PANEL_POSITION_TOP; 17 if (strcasecmp(valid[i], argv[0]) == 0) {
18 } else if (strcasecmp("bottom", argv[0]) == 0) { 18 wlr_log(L_DEBUG, "Setting bar position '%s' for bar: %s",
19 config->current_bar->position = DESKTOP_SHELL_PANEL_POSITION_BOTTOM; 19 argv[0], config->current_bar->id);
20 } else if (strcasecmp("left", argv[0]) == 0) { 20 config->current_bar->position = strdup(argv[0]);
21 sway_log(L_INFO, "Warning: swaybar currently only supports top and bottom positioning. YMMV"); 21 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
22 config->current_bar->position = DESKTOP_SHELL_PANEL_POSITION_LEFT; 22 }
23 } else if (strcasecmp("right", argv[0]) == 0) {
24 sway_log(L_INFO, "Warning: swaybar currently only supports top and bottom positioning. YMMV");
25 config->current_bar->position = DESKTOP_SHELL_PANEL_POSITION_RIGHT;
26 } else {
27 error = cmd_results_new(CMD_INVALID, "position", "Invalid value %s", argv[0]);
28 return error;
29 } 23 }
30 24 return cmd_results_new(CMD_INVALID,
31 sway_log(L_DEBUG, "Setting bar position '%s' for bar: %s", argv[0], config->current_bar->id); 25 "position", "Invalid value %s", argv[0]);
32 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
33} 26}