aboutsummaryrefslogtreecommitdiffstats
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.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/sway/commands/bar/position.c b/sway/commands/bar/position.c
new file mode 100644
index 00000000..9c580483
--- /dev/null
+++ b/sway/commands/bar/position.c
@@ -0,0 +1,26 @@
1#define _POSIX_C_SOURCE 200809L
2#include <string.h>
3#include <strings.h>
4#include "sway/commands.h"
5#include "log.h"
6
7struct cmd_results *bar_cmd_position(int argc, char **argv) {
8 struct cmd_results *error = NULL;
9 if ((error = checkarg(argc, "position", EXPECTED_EQUAL_TO, 1))) {
10 return error;
11 }
12 if (!config->current_bar) {
13 return cmd_results_new(CMD_FAILURE, "position", "No bar defined.");
14 }
15 char *valid[] = { "top", "bottom", "left", "right" };
16 for (size_t i = 0; i < sizeof(valid) / sizeof(valid[0]); ++i) {
17 if (strcasecmp(valid[i], argv[0]) == 0) {
18 wlr_log(L_DEBUG, "Setting bar position '%s' for bar: %s",
19 argv[0], config->current_bar->id);
20 config->current_bar->position = strdup(argv[0]);
21 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
22 }
23 }
24 return cmd_results_new(CMD_INVALID,
25 "position", "Invalid value %s", argv[0]);
26}