diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-08-19 10:36:33 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-08-19 10:36:33 -0400 |
commit | 2d3bd3c74772e72ed6119549428150c7318fe456 (patch) | |
tree | 5fbd81bd3fa24583ee932b296f146340b6507c59 /sway/config.c | |
parent | 0f29f048167739c6f92d241d2aacbfcf6972c39c (diff) | |
parent | 0e4df85ba1a931a812c441572f352090a934e6bc (diff) |
Merge pull request #86 from Luminarys/master
Fixed config loading
Diffstat (limited to 'sway/config.c')
-rw-r--r-- | sway/config.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/sway/config.c b/sway/config.c index f38e37b6..ce05bc68 100644 --- a/sway/config.c +++ b/sway/config.c @@ -71,13 +71,21 @@ static const char *search_paths[] = { }; static char *get_config_path() { - char *home = strdup(getenv("HOME")); - char *config = strdup(getenv("XDG_CONFIG_HOME")); - if (!config) { - const char *def = "/.config/sway"; + char *home = getenv("HOME"); + if (home) { + home = strdup(getenv("HOME")); + } + char *config = getenv("XDG_CONFIG_HOME"); + if (config) { + config = strdup(getenv("XDG_CONFIG_HOME")); + } else if (home) { + const char *def = "/.config"; config = malloc(strlen(home) + strlen(def) + 1); strcpy(config, home); strcat(config, def); + } else { + home = strdup(""); + config = strdup(""); } // Set up a temporary config for holding set variables |