aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Mikkel Oscar Lyderik <mikkeloscar@gmail.com>2016-03-24 22:13:42 +0100
committerLibravatar Mikkel Oscar Lyderik <mikkeloscar@gmail.com>2016-03-24 22:20:25 +0100
commit938ff29b7b14d9840a92acb1d1ee4192bfc8e89e (patch)
tree9ed266fe8b9ab0f720d1defb28f085b26bf9cd98 /sway
parentMake the nvidia warning louder (diff)
downloadsway-938ff29b7b14d9840a92acb1d1ee4192bfc8e89e.tar.gz
sway-938ff29b7b14d9840a92acb1d1ee4192bfc8e89e.tar.zst
sway-938ff29b7b14d9840a92acb1d1ee4192bfc8e89e.zip
Gracefully exit when config is not found
This makes sure that sway will gracefully exit if the config is not found or sway is unable to read it.
Diffstat (limited to 'sway')
-rw-r--r--sway/config.c8
-rw-r--r--sway/main.c3
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) {
256 256
257 FILE *f = fopen(path, "r"); 257 FILE *f = fopen(path, "r");
258 if (!f) { 258 if (!f) {
259 fprintf(stderr, "Unable to open %s for reading", path); 259 sway_log(L_ERROR, "Unable to open %s for reading", path);
260 free(path); 260 free(path);
261 return false; 261 return false;
262 } 262 }
@@ -272,7 +272,11 @@ bool load_config(const char *file) {
272 272
273 update_active_bar_modifiers(); 273 update_active_bar_modifiers();
274 274
275 return config_load_success; 275 if (!config_load_success) {
276 sway_log(L_ERROR, "Error(s) loading config!");
277 }
278
279 return true;
276} 280}
277 281
278bool read_config(FILE *file, bool is_active) { 282bool 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) {
211 } 211 }
212 212
213 if (!load_config(config_path)) { 213 if (!load_config(config_path)) {
214 sway_log(L_ERROR, "Error(s) loading config!"); 214 sway_terminate(EXIT_FAILURE);
215 } 215 }
216
216 if (config_path) { 217 if (config_path) {
217 free(config_path); 218 free(config_path);
218 } 219 }