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/output.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/output.c')
-rw-r--r-- | sway/commands/bar/output.c | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/sway/commands/bar/output.c b/sway/commands/bar/output.c deleted file mode 100644 index a5710bc0..00000000 --- a/sway/commands/bar/output.c +++ /dev/null | |||
@@ -1,50 +0,0 @@ | |||
1 | #define _XOPEN_SOURCE 500 | ||
2 | #include <string.h> | ||
3 | #include "sway/commands.h" | ||
4 | #include "list.h" | ||
5 | #include "log.h" | ||
6 | |||
7 | struct cmd_results *bar_cmd_output(int argc, char **argv) { | ||
8 | struct cmd_results *error = NULL; | ||
9 | if ((error = checkarg(argc, "output", EXPECTED_EQUAL_TO, 1))) { | ||
10 | return error; | ||
11 | } | ||
12 | |||
13 | if (!config->current_bar) { | ||
14 | return cmd_results_new(CMD_FAILURE, "output", "No bar defined."); | ||
15 | } | ||
16 | |||
17 | const char *output = argv[0]; | ||
18 | list_t *outputs = config->current_bar->outputs; | ||
19 | if (!outputs) { | ||
20 | outputs = create_list(); | ||
21 | config->current_bar->outputs = outputs; | ||
22 | } | ||
23 | |||
24 | int i; | ||
25 | int add_output = 1; | ||
26 | if (strcmp("*", output) == 0) { | ||
27 | // remove all previous defined outputs and replace with '*' | ||
28 | for (i = 0; i < outputs->length; ++i) { | ||
29 | free(outputs->items[i]); | ||
30 | list_del(outputs, i); | ||
31 | } | ||
32 | } else { | ||
33 | // only add output if not already defined with either the same | ||
34 | // name or as '*' | ||
35 | for (i = 0; i < outputs->length; ++i) { | ||
36 | const char *find = outputs->items[i]; | ||
37 | if (strcmp("*", find) == 0 || strcmp(output, find) == 0) { | ||
38 | add_output = 0; | ||
39 | break; | ||
40 | } | ||
41 | } | ||
42 | } | ||
43 | |||
44 | if (add_output) { | ||
45 | list_add(outputs, strdup(output)); | ||
46 | sway_log(L_DEBUG, "Adding bar: '%s' to output '%s'", config->current_bar->id, output); | ||
47 | } | ||
48 | |||
49 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
50 | } | ||