diff options
author | 2015-08-13 14:41:29 -0500 | |
---|---|---|
committer | 2015-08-13 14:41:36 -0500 | |
commit | ea9efc884d92d32863287b8d8e5a5f8bd631f9f5 (patch) | |
tree | 363ec049383bbdd587ebec45625c25423b8165eb | |
parent | Even more style fixes (diff) | |
download | sway-ea9efc884d92d32863287b8d8e5a5f8bd631f9f5.tar.gz sway-ea9efc884d92d32863287b8d8e5a5f8bd631f9f5.tar.zst sway-ea9efc884d92d32863287b8d8e5a5f8bd631f9f5.zip |
Allowed for execd commands to be spawned after abort
-rw-r--r-- | sway/commands.c | 2 | ||||
-rw-r--r-- | sway/config.c | 44 | ||||
-rw-r--r-- | sway/config.h | 5 | ||||
-rw-r--r-- | sway/handlers.c | 9 | ||||
-rw-r--r-- | sway/main.c | 3 |
5 files changed, 43 insertions, 20 deletions
diff --git a/sway/commands.c b/sway/commands.c index cae35237..c95b9858 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -229,7 +229,7 @@ static bool cmd_set(struct sway_config *config, int argc, char **argv) { | |||
229 | 229 | ||
230 | static bool _do_split(struct sway_config *config, int argc, char **argv, int layout) { | 230 | static bool _do_split(struct sway_config *config, int argc, char **argv, int layout) { |
231 | char *name = layout == L_VERT ? "splitv": | 231 | char *name = layout == L_VERT ? "splitv": |
232 | layout == L_HORIZ ? "splith":"split"; | 232 | layout == L_HORIZ ? "splith":"split"; |
233 | if (!checkarg(argc, name, EXPECTED_EQUAL_TO, 0)) { | 233 | if (!checkarg(argc, name, EXPECTED_EQUAL_TO, 0)) { |
234 | return false; | 234 | return false; |
235 | } | 235 | } |
diff --git a/sway/config.c b/sway/config.c index 869fa077..d96d23fc 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -25,9 +25,16 @@ bool load_config() { | |||
25 | return false; | 25 | return false; |
26 | } | 26 | } |
27 | free(temp); | 27 | free(temp); |
28 | config = read_config(f, false); | 28 | |
29 | bool config_load_success; | ||
30 | if (config) { | ||
31 | config_load_success = read_config(f, true); | ||
32 | } else { | ||
33 | config_load_success = read_config(f, false); | ||
34 | } | ||
29 | fclose(f); | 35 | fclose(f); |
30 | return true; | 36 | |
37 | return config_load_success; | ||
31 | } | 38 | } |
32 | 39 | ||
33 | void config_defaults(struct sway_config *config) { | 40 | void config_defaults(struct sway_config *config) { |
@@ -42,14 +49,17 @@ void config_defaults(struct sway_config *config) { | |||
42 | config->focus_follows_mouse = true; | 49 | config->focus_follows_mouse = true; |
43 | config->mouse_warping = true; | 50 | config->mouse_warping = true; |
44 | config->reloading = false; | 51 | config->reloading = false; |
52 | config->active = false; | ||
53 | config->failed = false; | ||
45 | } | 54 | } |
46 | 55 | ||
47 | struct sway_config *read_config(FILE *file, bool is_active) { | 56 | bool read_config(FILE *file, bool is_active) { |
48 | struct sway_config *config = malloc(sizeof(struct sway_config)); | 57 | struct sway_config *temp_config = malloc(sizeof(struct sway_config)); |
49 | config_defaults(config); | 58 | config_defaults(temp_config); |
50 | |||
51 | if (is_active) { | 59 | if (is_active) { |
52 | config->reloading = true; | 60 | sway_log(L_DEBUG, "Performing configuration file reload"); |
61 | temp_config->reloading = true; | ||
62 | temp_config->active = true; | ||
53 | } | 63 | } |
54 | 64 | ||
55 | bool success = true; | 65 | bool success = true; |
@@ -72,14 +82,19 @@ struct sway_config *read_config(FILE *file, bool is_active) { | |||
72 | // Any command which would require wlc to be initialized | 82 | // Any command which would require wlc to be initialized |
73 | // should be queued for later execution | 83 | // should be queued for later execution |
74 | list_t *args = split_string(line, " "); | 84 | list_t *args = split_string(line, " "); |
75 | if (strcmp("workspace", args->items[0]) == 0) { | 85 | if (!is_active && ( |
86 | strcmp("workspace", args->items[0]) == 0 || | ||
87 | strcmp("exec", args->items[0]) == 0 || | ||
88 | strcmp("exec_always", args->items[0]) == 0 )) { | ||
76 | sway_log(L_DEBUG, "Deferring command %s", line); | 89 | sway_log(L_DEBUG, "Deferring command %s", line); |
90 | |||
77 | char *cmd = malloc(strlen(line) + 1); | 91 | char *cmd = malloc(strlen(line) + 1); |
78 | strcpy(cmd, line); | 92 | strcpy(cmd, line); |
79 | list_add(config->cmd_queue, cmd); | 93 | list_add(temp_config->cmd_queue, cmd); |
80 | } else if (!temp_depth && !handle_command(config, line)) { | 94 | } else if (!temp_depth && !handle_command(temp_config, line)) { |
81 | sway_log(L_DEBUG, "Config load failed for line %s", line); | 95 | sway_log(L_DEBUG, "Config load failed for line %s", line); |
82 | success = false; | 96 | success = false; |
97 | temp_config->failed = true; | ||
83 | } | 98 | } |
84 | list_free(args); | 99 | list_free(args); |
85 | 100 | ||
@@ -90,15 +105,12 @@ _continue: | |||
90 | free(line); | 105 | free(line); |
91 | } | 106 | } |
92 | 107 | ||
93 | if (success == false) { | ||
94 | exit(1); | ||
95 | } | ||
96 | |||
97 | if (is_active) { | 108 | if (is_active) { |
98 | config->reloading = false; | 109 | temp_config->reloading = false; |
99 | } | 110 | } |
111 | config = temp_config; | ||
100 | 112 | ||
101 | return config; | 113 | return success; |
102 | } | 114 | } |
103 | 115 | ||
104 | char *do_var_replacement(struct sway_config *config, char *str) { | 116 | char *do_var_replacement(struct sway_config *config, char *str) { |
diff --git a/sway/config.h b/sway/config.h index f55453a3..c9fd374c 100644 --- a/sway/config.h +++ b/sway/config.h | |||
@@ -30,12 +30,13 @@ struct sway_config { | |||
30 | // Flags | 30 | // Flags |
31 | bool focus_follows_mouse; | 31 | bool focus_follows_mouse; |
32 | bool mouse_warping; | 32 | bool mouse_warping; |
33 | 33 | bool active; | |
34 | bool failed; | ||
34 | bool reloading; | 35 | bool reloading; |
35 | }; | 36 | }; |
36 | 37 | ||
37 | bool load_config(); | 38 | bool load_config(); |
38 | struct sway_config *read_config(FILE *file, bool is_active); | 39 | bool read_config(FILE *file, bool is_active); |
39 | char *do_var_replacement(struct sway_config *config, char *str); | 40 | char *do_var_replacement(struct sway_config *config, char *str); |
40 | 41 | ||
41 | extern struct sway_config *config; | 42 | extern struct sway_config *config; |
diff --git a/sway/handlers.c b/sway/handlers.c index 4411b947..48c6cbf7 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -8,6 +8,7 @@ | |||
8 | #include "config.h" | 8 | #include "config.h" |
9 | #include "commands.h" | 9 | #include "commands.h" |
10 | #include "handlers.h" | 10 | #include "handlers.h" |
11 | #include "stringop.h" | ||
11 | 12 | ||
12 | static bool handle_output_created(wlc_handle output) { | 13 | static bool handle_output_created(wlc_handle output) { |
13 | add_output(output); | 14 | add_output(output); |
@@ -165,11 +166,19 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w | |||
165 | 166 | ||
166 | static void handle_wlc_ready(void) { | 167 | static void handle_wlc_ready(void) { |
167 | sway_log(L_DEBUG, "Compositor is ready, executing cmds in queue"); | 168 | sway_log(L_DEBUG, "Compositor is ready, executing cmds in queue"); |
169 | |||
168 | int i; | 170 | int i; |
169 | for (i = 0; i < config->cmd_queue->length; ++i) { | 171 | for (i = 0; i < config->cmd_queue->length; ++i) { |
170 | handle_command(config, config->cmd_queue->items[i]); | 172 | handle_command(config, config->cmd_queue->items[i]); |
171 | } | 173 | } |
172 | free_flat_list(config->cmd_queue); | 174 | free_flat_list(config->cmd_queue); |
175 | |||
176 | if (config->failed) { | ||
177 | sway_log(L_ERROR, "Programs have been execd, aborting!"); | ||
178 | sway_abort("Unable to load config"); | ||
179 | } | ||
180 | |||
181 | config->active = true; | ||
173 | } | 182 | } |
174 | 183 | ||
175 | 184 | ||
diff --git a/sway/main.c b/sway/main.c index b48d4b19..061564e2 100644 --- a/sway/main.c +++ b/sway/main.c | |||
@@ -19,7 +19,7 @@ int main(int argc, char **argv) { | |||
19 | signal(SIGCHLD, sigchld_handle); | 19 | signal(SIGCHLD, sigchld_handle); |
20 | 20 | ||
21 | if (!load_config()) { | 21 | if (!load_config()) { |
22 | sway_abort("Unable to load config"); | 22 | sway_log(L_ERROR, "Config load failed, aborting sway post init!"); |
23 | } | 23 | } |
24 | 24 | ||
25 | setenv("WLC_DIM", "0", 0); | 25 | setenv("WLC_DIM", "0", 0); |
@@ -29,6 +29,7 @@ int main(int argc, char **argv) { | |||
29 | setenv("DISPLAY", ":1", 1); | 29 | setenv("DISPLAY", ":1", 1); |
30 | 30 | ||
31 | wlc_run(); | 31 | wlc_run(); |
32 | |||
32 | return 0; | 33 | return 0; |
33 | } | 34 | } |
34 | 35 | ||