diff options
Diffstat (limited to 'sway/config.c')
-rw-r--r-- | sway/config.c | 44 |
1 files changed, 28 insertions, 16 deletions
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() { return false; } free(temp); - config = read_config(f, false); + + bool config_load_success; + if (config) { + config_load_success = read_config(f, true); + } else { + config_load_success = read_config(f, false); + } fclose(f); - return true; + + return config_load_success; } void config_defaults(struct sway_config *config) { @@ -42,14 +49,17 @@ void config_defaults(struct sway_config *config) { config->focus_follows_mouse = true; config->mouse_warping = true; config->reloading = false; + config->active = false; + config->failed = false; } -struct sway_config *read_config(FILE *file, bool is_active) { - struct sway_config *config = malloc(sizeof(struct sway_config)); - config_defaults(config); - +bool read_config(FILE *file, bool is_active) { + struct sway_config *temp_config = malloc(sizeof(struct sway_config)); + config_defaults(temp_config); if (is_active) { - config->reloading = true; + sway_log(L_DEBUG, "Performing configuration file reload"); + temp_config->reloading = true; + temp_config->active = true; } bool success = true; @@ -72,14 +82,19 @@ struct sway_config *read_config(FILE *file, bool is_active) { // Any command which would require wlc to be initialized // should be queued for later execution list_t *args = split_string(line, " "); - if (strcmp("workspace", args->items[0]) == 0) { + if (!is_active && ( + strcmp("workspace", args->items[0]) == 0 || + strcmp("exec", args->items[0]) == 0 || + strcmp("exec_always", args->items[0]) == 0 )) { sway_log(L_DEBUG, "Deferring command %s", line); + char *cmd = malloc(strlen(line) + 1); strcpy(cmd, line); - list_add(config->cmd_queue, cmd); - } else if (!temp_depth && !handle_command(config, line)) { + list_add(temp_config->cmd_queue, cmd); + } else if (!temp_depth && !handle_command(temp_config, line)) { sway_log(L_DEBUG, "Config load failed for line %s", line); success = false; + temp_config->failed = true; } list_free(args); @@ -90,15 +105,12 @@ _continue: free(line); } - if (success == false) { - exit(1); - } - if (is_active) { - config->reloading = false; + temp_config->reloading = false; } + config = temp_config; - return config; + return success; } char *do_var_replacement(struct sway_config *config, char *str) { |