diff options
author | emersion <contact@emersion.fr> | 2018-08-02 08:11:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-02 08:11:10 +0100 |
commit | 47bf4ed0cbf104d09bba7f39acbf2ceb84c2c694 (patch) | |
tree | 8f0085c1829ab97a920acd9d5116732779177631 /sway/commands/reload.c | |
parent | d10ccc1eb144e4de2477398f6b11753f6b7df70b (diff) | |
parent | 9564c73c0ddca9d7b45f0476fcaee8bd878d8345 (diff) |
Merge branch 'master' into fix-resize-wiggle
Diffstat (limited to 'sway/commands/reload.c')
-rw-r--r-- | sway/commands/reload.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/sway/commands/reload.c b/sway/commands/reload.c index cea6a94b..5c1b19b4 100644 --- a/sway/commands/reload.c +++ b/sway/commands/reload.c @@ -1,17 +1,46 @@ +#define _XOPEN_SOURCE 500 +#include <string.h> #include "sway/commands.h" #include "sway/config.h" +#include "sway/ipc-server.h" #include "sway/tree/arrange.h" +#include "list.h" struct cmd_results *cmd_reload(int argc, char **argv) { struct cmd_results *error = NULL; if ((error = checkarg(argc, "reload", EXPECTED_EQUAL_TO, 0))) { return error; } + + // store bar ids to check against new bars for barconfig_update events + list_t *bar_ids = create_list(); + for (int i = 0; i < config->bars->length; ++i) { + struct bar_config *bar = config->bars->items[i]; + list_add(bar_ids, strdup(bar->id)); + } + if (!load_main_config(config->current_config_path, true)) { return cmd_results_new(CMD_FAILURE, "reload", "Error(s) reloading config."); } + ipc_event_workspace(NULL, NULL, "reload"); load_swaybars(); + + for (int i = 0; i < config->bars->length; ++i) { + struct bar_config *bar = config->bars->items[i]; + for (int j = 0; j < bar_ids->length; ++j) { + if (strcmp(bar->id, bar_ids->items[j]) == 0) { + ipc_event_barconfig_update(bar); + break; + } + } + } + + for (int i = 0; i < bar_ids->length; ++i) { + free(bar_ids->items[i]); + } + list_free(bar_ids); + arrange_windows(&root_container); return cmd_results_new(CMD_SUCCESS, NULL, NULL); } |