diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2018-08-01 23:54:40 -0400 |
---|---|---|
committer | Brian Ashworth <bosrsf04@gmail.com> | 2018-08-03 10:37:35 -0400 |
commit | f9a6407111a8730df51258c3b07502814a8ab3e1 (patch) | |
tree | 6cf180159caf4a45a8f37b026b2769d24468a07b /sway/commands | |
parent | 3e2bf7f3a550db995a38808e0abd53fefab96f80 (diff) |
Show swaynag on config errors
Diffstat (limited to 'sway/commands')
-rw-r--r-- | sway/commands/include.c | 15 | ||||
-rw-r--r-- | sway/commands/reload.c | 19 |
2 files changed, 30 insertions, 4 deletions
diff --git a/sway/commands/include.c b/sway/commands/include.c index 1ba9a10d..72fec7cc 100644 --- a/sway/commands/include.c +++ b/sway/commands/include.c @@ -7,8 +7,19 @@ struct cmd_results *cmd_include(int argc, char **argv) { return error; } - if (!load_include_configs(argv[0], config)) { - return cmd_results_new(CMD_INVALID, "include", "Failed to include sub configuration file: %s", argv[0]); + char *errors = NULL; + if (!load_include_configs(argv[0], config, &errors)) { + struct cmd_results *result = cmd_results_new(CMD_INVALID, "include", + "Failed to include sub configuration file: %s", argv[0]); + free(errors); + return result; + } + + if (errors) { + struct cmd_results *result = cmd_results_new(CMD_INVALID, "include", + "There are errors in the included config\n%s", errors); + free(errors); + return result; } return cmd_results_new(CMD_SUCCESS, NULL, NULL); diff --git a/sway/commands/reload.c b/sway/commands/reload.c index 5c1b19b4..9bf671d9 100644 --- a/sway/commands/reload.c +++ b/sway/commands/reload.c @@ -1,4 +1,5 @@ #define _XOPEN_SOURCE 500 +#include <signal.h> #include <string.h> #include "sway/commands.h" #include "sway/config.h" @@ -19,8 +20,11 @@ struct cmd_results *cmd_reload(int argc, char **argv) { 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."); + char *errors = NULL; + if (!load_main_config(config->current_config_path, true, &errors)) { + free(errors); + return cmd_results_new(CMD_FAILURE, "reload", + "Error(s) reloading config."); } ipc_event_workspace(NULL, NULL, "reload"); @@ -42,5 +46,16 @@ struct cmd_results *cmd_reload(int argc, char **argv) { list_free(bar_ids); arrange_windows(&root_container); + + if (config->swaynag_pid > 0) { + kill(config->swaynag_pid, SIGTERM); + config->swaynag_pid = -1; + } + + if (errors) { + spawn_swaynag_config_errors(config, errors); + free(errors); + } + return cmd_results_new(CMD_SUCCESS, NULL, NULL); } |