summaryrefslogtreecommitdiffstats
path: root/sway/commands/bar/position.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-03-29 17:20:03 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2018-03-29 22:11:08 -0400
commitbf7a4cd0ebd465a0597e9eec0142fad222b396de (patch)
treef95c4b8cd8e7d06eaa1b688d3bcbb3249dc21129 /sway/commands/bar/position.c
parentImplement enough IPC for swaybar to work (diff)
downloadsway-bf7a4cd0ebd465a0597e9eec0142fad222b396de.tar.gz
sway-bf7a4cd0ebd465a0597e9eec0142fad222b396de.tar.zst
sway-bf7a4cd0ebd465a0597e9eec0142fad222b396de.zip
Add bar configuration commands
Diffstat (limited to 'sway/commands/bar/position.c')
-rw-r--r--sway/commands/bar/position.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/sway/commands/bar/position.c b/sway/commands/bar/position.c
new file mode 100644
index 00000000..efa8c0bc
--- /dev/null
+++ b/sway/commands/bar/position.c
@@ -0,0 +1,29 @@
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
13 if (!config->current_bar) {
14 return cmd_results_new(CMD_FAILURE, "position", "No bar defined.");
15 }
16
17 char *valid[] = { "top", "bottom", "left", "right" };
18 for (size_t i = 0; i < sizeof(valid) / sizeof(valid[0]); ++i) {
19 if (strcasecmp(valid[i], argv[0]) == 0) {
20 wlr_log(L_DEBUG, "Setting bar position '%s' for bar: %s",
21 argv[0], config->current_bar->id);
22 config->current_bar->position = strdup(argv[0]);
23 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
24 }
25 }
26
27 error = cmd_results_new(CMD_INVALID, "position", "Invalid value %s", argv[0]);
28 return error;
29}