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 | Merge pull request #2417 from marienz/swaynag-includes (diff) | |
download | sway-f9a6407111a8730df51258c3b07502814a8ab3e1.tar.gz sway-f9a6407111a8730df51258c3b07502814a8ab3e1.tar.zst sway-f9a6407111a8730df51258c3b07502814a8ab3e1.zip |
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) { | |||
7 | return error; | 7 | return error; |
8 | } | 8 | } |
9 | 9 | ||
10 | if (!load_include_configs(argv[0], config)) { | 10 | char *errors = NULL; |
11 | return cmd_results_new(CMD_INVALID, "include", "Failed to include sub configuration file: %s", argv[0]); | 11 | if (!load_include_configs(argv[0], config, &errors)) { |
12 | struct cmd_results *result = cmd_results_new(CMD_INVALID, "include", | ||
13 | "Failed to include sub configuration file: %s", argv[0]); | ||
14 | free(errors); | ||
15 | return result; | ||
16 | } | ||
17 | |||
18 | if (errors) { | ||
19 | struct cmd_results *result = cmd_results_new(CMD_INVALID, "include", | ||
20 | "There are errors in the included config\n%s", errors); | ||
21 | free(errors); | ||
22 | return result; | ||
12 | } | 23 | } |
13 | 24 | ||
14 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 25 | 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 @@ | |||
1 | #define _XOPEN_SOURCE 500 | 1 | #define _XOPEN_SOURCE 500 |
2 | #include <signal.h> | ||
2 | #include <string.h> | 3 | #include <string.h> |
3 | #include "sway/commands.h" | 4 | #include "sway/commands.h" |
4 | #include "sway/config.h" | 5 | #include "sway/config.h" |
@@ -19,8 +20,11 @@ struct cmd_results *cmd_reload(int argc, char **argv) { | |||
19 | list_add(bar_ids, strdup(bar->id)); | 20 | list_add(bar_ids, strdup(bar->id)); |
20 | } | 21 | } |
21 | 22 | ||
22 | if (!load_main_config(config->current_config_path, true)) { | 23 | char *errors = NULL; |
23 | return cmd_results_new(CMD_FAILURE, "reload", "Error(s) reloading config."); | 24 | if (!load_main_config(config->current_config_path, true, &errors)) { |
25 | free(errors); | ||
26 | return cmd_results_new(CMD_FAILURE, "reload", | ||
27 | "Error(s) reloading config."); | ||
24 | } | 28 | } |
25 | ipc_event_workspace(NULL, NULL, "reload"); | 29 | ipc_event_workspace(NULL, NULL, "reload"); |
26 | 30 | ||
@@ -42,5 +46,16 @@ struct cmd_results *cmd_reload(int argc, char **argv) { | |||
42 | list_free(bar_ids); | 46 | list_free(bar_ids); |
43 | 47 | ||
44 | arrange_windows(&root_container); | 48 | arrange_windows(&root_container); |
49 | |||
50 | if (config->swaynag_pid > 0) { | ||
51 | kill(config->swaynag_pid, SIGTERM); | ||
52 | config->swaynag_pid = -1; | ||
53 | } | ||
54 | |||
55 | if (errors) { | ||
56 | spawn_swaynag_config_errors(config, errors); | ||
57 | free(errors); | ||
58 | } | ||
59 | |||
45 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 60 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
46 | } | 61 | } |