From 9beb78ffa18c0819fce751c502c06e9c5acea33c Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Thu, 16 May 2019 23:29:50 +0000 Subject: [PATCH] commands/bar: always reload after config change Prior to this patch, running a command like this wouldn't do anything: swaymsg bar bar-0 color background #ff0000 The only exception was the status_command subcommand, because it reloaded the bar after updating the configuration. This patch makes every bar subcommand reload the bar after config changes, so bar config can be changed on the fly like the rest of sway's configuration. Note that, if two bars are stacked, and the first bar's config is changed, it will be removed and readded, so the order of the bars will be stopped. I believe that, despite this shortcoming, this change is strictly better than the current behavior, in which config can't be changed live at all, especially in what must surely be the far most common case of having only a single bar. Since changing status_command already did this, I assume that this edge-case is acceptable. --- sway/commands/bar.c | 6 +++--- sway/commands/bar/status_command.c | 4 ---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/sway/commands/bar.c b/sway/commands/bar.c index 73be70406..a72c540bd 100644 --- a/sway/commands/bar.c +++ b/sway/commands/bar.c @@ -125,10 +125,10 @@ struct cmd_results *cmd_bar(int argc, char **argv) { struct cmd_results *res = config_subcommand(argv, argc, bar_handlers, sizeof(bar_handlers)); + if (res && config->active && !config->validating) { + load_swaybar(config->current_bar); + } if (!config->reading) { - if (spawn) { - load_swaybar(config->current_bar); - } config->current_bar = NULL; } return res; diff --git a/sway/commands/bar/status_command.c b/sway/commands/bar/status_command.c index 0b58e5fa2..c0ea6d743 100644 --- a/sway/commands/bar/status_command.c +++ b/sway/commands/bar/status_command.c @@ -23,9 +23,5 @@ struct cmd_results *bar_cmd_status_command(int argc, char **argv) { free(new_command); } - if (config->active && !config->validating) { - load_swaybar(config->current_bar); - } - return cmd_results_new(CMD_SUCCESS, NULL); }