diff options
author | Drew DeVault <sir@cmpwn.com> | 2016-03-24 17:27:03 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2016-03-24 17:27:03 -0400 |
commit | dcf5c67681128c62fd8e807f9681b334f0485f80 (patch) | |
tree | 9ed266fe8b9ab0f720d1defb28f085b26bf9cd98 | |
parent | 06107bb44eddec993354883436767b931f2aa4d7 (diff) | |
parent | 938ff29b7b14d9840a92acb1d1ee4192bfc8e89e (diff) |
Merge pull request #537 from mikkeloscar/exit-on-config-missing
Gracefully exit when config is not found
-rw-r--r-- | sway/config.c | 8 | ||||
-rw-r--r-- | sway/main.c | 3 |
2 files changed, 8 insertions, 3 deletions
diff --git a/sway/config.c b/sway/config.c index ebf7546d..a5fdf850 100644 --- a/sway/config.c +++ b/sway/config.c @@ -256,7 +256,7 @@ bool load_config(const char *file) { FILE *f = fopen(path, "r"); if (!f) { - fprintf(stderr, "Unable to open %s for reading", path); + sway_log(L_ERROR, "Unable to open %s for reading", path); free(path); return false; } @@ -272,7 +272,11 @@ bool load_config(const char *file) { update_active_bar_modifiers(); - return config_load_success; + if (!config_load_success) { + sway_log(L_ERROR, "Error(s) loading config!"); + } + + return true; } bool read_config(FILE *file, bool is_active) { diff --git a/sway/main.c b/sway/main.c index eef1ad19..c4a5d497 100644 --- a/sway/main.c +++ b/sway/main.c @@ -211,8 +211,9 @@ int main(int argc, char **argv) { } if (!load_config(config_path)) { - sway_log(L_ERROR, "Error(s) loading config!"); + sway_terminate(EXIT_FAILURE); } + if (config_path) { free(config_path); } |