diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-11-18 11:22:02 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2017-11-18 11:22:02 -0500 |
commit | 733993a651c71f7e2198d505960d6bbd31e0e107 (patch) | |
tree | e51732c5872b624e73355f9e5b3f762101f3cd0d /sway/commands/bar.c | |
parent | Initial (awful) pass on xdg shell support (diff) | |
download | sway-733993a651c71f7e2198d505960d6bbd31e0e107.tar.gz sway-733993a651c71f7e2198d505960d6bbd31e0e107.tar.zst sway-733993a651c71f7e2198d505960d6bbd31e0e107.zip |
Move everything to sway/old/
Diffstat (limited to 'sway/commands/bar.c')
-rw-r--r-- | sway/commands/bar.c | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/sway/commands/bar.c b/sway/commands/bar.c deleted file mode 100644 index 04745a6e..00000000 --- a/sway/commands/bar.c +++ /dev/null | |||
@@ -1,59 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <string.h> | ||
3 | #include <strings.h> | ||
4 | #include "sway/commands.h" | ||
5 | #include "sway/config.h" | ||
6 | #include "log.h" | ||
7 | #include "util.h" | ||
8 | |||
9 | struct cmd_results *cmd_bar(int argc, char **argv) { | ||
10 | struct cmd_results *error = NULL; | ||
11 | if ((error = checkarg(argc, "bar", EXPECTED_AT_LEAST, 1))) { | ||
12 | return error; | ||
13 | } | ||
14 | |||
15 | if (config->reading && strcmp("{", argv[0]) != 0) { | ||
16 | return cmd_results_new(CMD_INVALID, "bar", | ||
17 | "Expected '{' at start of bar config definition."); | ||
18 | } | ||
19 | |||
20 | if (!config->reading) { | ||
21 | if (argc > 1) { | ||
22 | if (strcasecmp("mode", argv[0]) == 0) { | ||
23 | return bar_cmd_mode(argc-1, argv + 1); | ||
24 | } | ||
25 | |||
26 | if (strcasecmp("hidden_state", argv[0]) == 0) { | ||
27 | return bar_cmd_hidden_state(argc-1, argv + 1); | ||
28 | } | ||
29 | } | ||
30 | |||
31 | return cmd_results_new(CMD_FAILURE, "bar", "Can only be used in config file."); | ||
32 | } | ||
33 | |||
34 | // Create new bar with default values | ||
35 | struct bar_config *bar = default_bar_config(); | ||
36 | if (!bar) { | ||
37 | return cmd_results_new(CMD_FAILURE, "bar", "Unable to allocate bar state"); | ||
38 | } | ||
39 | |||
40 | // set bar id | ||
41 | int i; | ||
42 | for (i = 0; i < config->bars->length; ++i) { | ||
43 | if (bar == config->bars->items[i]) { | ||
44 | const int len = 5 + numlen(i); // "bar-" + i + \0 | ||
45 | bar->id = malloc(len * sizeof(char)); | ||
46 | if (bar->id) { | ||
47 | snprintf(bar->id, len, "bar-%d", i); | ||
48 | } else { | ||
49 | return cmd_results_new(CMD_FAILURE, "bar", "Unable to allocate bar ID"); | ||
50 | } | ||
51 | break; | ||
52 | } | ||
53 | } | ||
54 | |||
55 | // Set current bar | ||
56 | config->current_bar = bar; | ||
57 | sway_log(L_DEBUG, "Configuring bar %s", bar->id); | ||
58 | return cmd_results_new(CMD_BLOCK_BAR, NULL, NULL); | ||
59 | } | ||