diff options
Diffstat (limited to 'swaynag/config.c')
-rw-r--r-- | swaynag/config.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/swaynag/config.c b/swaynag/config.c index 85aa380a..60bda3e0 100644 --- a/swaynag/config.c +++ b/swaynag/config.c | |||
@@ -304,25 +304,15 @@ char *swaynag_get_config_path(void) { | |||
304 | SYSCONFDIR "/swaynag/config", | 304 | SYSCONFDIR "/swaynag/config", |
305 | }; | 305 | }; |
306 | 306 | ||
307 | if (!getenv("XDG_CONFIG_HOME")) { | 307 | char *config_home = getenv("XDG_CONFIG_HOME"); |
308 | char *home = getenv("HOME"); | 308 | if (!config_home || *config_home) { |
309 | char *config_home = malloc(strlen(home) + strlen("/.config") + 1); | 309 | config_paths[1] = "$HOME/.config/swaynag/config"; |
310 | if (!config_home) { | ||
311 | wlr_log(WLR_ERROR, "Unable to allocate $HOME/.config"); | ||
312 | } else { | ||
313 | strcpy(config_home, home); | ||
314 | strcat(config_home, "/.config"); | ||
315 | setenv("XDG_CONFIG_HOME", config_home, 1); | ||
316 | wlr_log(WLR_DEBUG, "Set XDG_CONFIG_HOME to %s", config_home); | ||
317 | free(config_home); | ||
318 | } | ||
319 | } | 310 | } |
320 | 311 | ||
321 | wordexp_t p; | 312 | wordexp_t p; |
322 | char *path; | ||
323 | for (size_t i = 0; i < sizeof(config_paths) / sizeof(char *); ++i) { | 313 | for (size_t i = 0; i < sizeof(config_paths) / sizeof(char *); ++i) { |
324 | if (wordexp(config_paths[i], &p, 0) == 0) { | 314 | if (wordexp(config_paths[i], &p, 0) == 0) { |
325 | path = strdup(p.we_wordv[0]); | 315 | char *path = strdup(p.we_wordv[0]); |
326 | wordfree(&p); | 316 | wordfree(&p); |
327 | if (file_exists(path)) { | 317 | if (file_exists(path)) { |
328 | return path; | 318 | return path; |