diff options
author | Brian Ashworth <[email protected]> | 2019-09-02 21:41:11 -0400 |
---|---|---|
committer | Drew DeVault <[email protected]> | 2019-09-04 16:48:50 -1000 |
commit | 1fd2c6ba498e61f4fe823bf552f9d2fce8612de4 (patch) | |
tree | 8e2d9adab3451f1f05c76340d466a442c840e558 /sway/commands/bar/output.c | |
parent | 187306640ba8f2ab2f246a5030617ee985cf9223 (diff) |
swaybar: complete barconfig_update event handling
This adds complete support for the barconfig_update ipc event. This also
changes the bar command and subcommand handlers to correctly emit the
event. This makes it so all bar subcommands other than id and
swaybar_command are dynamically changeable at runtime. sway-bar.5 has
been updated accordingly
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) { bool add_output = true; if (strcmp("*", output) == 0) { // remove all previous defined outputs and replace with '*' - for (int i = 0; i < outputs->length; ++i) { - free(outputs->items[i]); - list_del(outputs, i); + while (outputs->length) { + free(outputs->items[0]); + list_del(outputs, 0); } } else { - // only add output if not already defined with either the same - // name or as '*' + // only add output if not already defined, if the list has '*', remove + // it, in favor of a manual list for (int i = 0; i < outputs->length; ++i) { const char *find = outputs->items[i]; - if (strcmp("*", find) == 0 || strcmp(output, find) == 0) { + if (strcmp("*", find) == 0) { + free(outputs->items[i]); + list_del(outputs, i); + } else if (strcmp(output, find) == 0) { add_output = false; break; } |