diff options
Diffstat (limited to 'sway/commands/bar/output.c')
-rw-r--r-- | sway/commands/bar/output.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sway/commands/bar/output.c b/sway/commands/bar/output.c index 6a78b30d..cac1d056 100644 --- a/sway/commands/bar/output.c +++ b/sway/commands/bar/output.c | |||
@@ -21,16 +21,19 @@ struct cmd_results *bar_cmd_output(int argc, char **argv) { | |||
21 | bool add_output = true; | 21 | bool add_output = true; |
22 | if (strcmp("*", output) == 0) { | 22 | if (strcmp("*", output) == 0) { |
23 | // remove all previous defined outputs and replace with '*' | 23 | // remove all previous defined outputs and replace with '*' |
24 | for (int i = 0; i < outputs->length; ++i) { | 24 | while (outputs->length) { |
25 | free(outputs->items[i]); | 25 | free(outputs->items[0]); |
26 | list_del(outputs, i); | 26 | list_del(outputs, 0); |
27 | } | 27 | } |
28 | } else { | 28 | } else { |
29 | // only add output if not already defined with either the same | 29 | // only add output if not already defined, if the list has '*', remove |
30 | // name or as '*' | 30 | // it, in favor of a manual list |
31 | for (int i = 0; i < outputs->length; ++i) { | 31 | for (int i = 0; i < outputs->length; ++i) { |
32 | const char *find = outputs->items[i]; | 32 | const char *find = outputs->items[i]; |
33 | if (strcmp("*", find) == 0 || strcmp(output, find) == 0) { | 33 | if (strcmp("*", find) == 0) { |
34 | free(outputs->items[i]); | ||
35 | list_del(outputs, i); | ||
36 | } else if (strcmp(output, find) == 0) { | ||
34 | add_output = false; | 37 | add_output = false; |
35 | break; | 38 | break; |
36 | } | 39 | } |