summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Luminarys <kizunanohikari@gmail.com>2015-08-19 09:33:30 -0500
committerLibravatar Luminarys <kizunanohikari@gmail.com>2015-08-19 09:33:30 -0500
commit0e4df85ba1a931a812c441572f352090a934e6bc (patch)
tree5fbd81bd3fa24583ee932b296f146340b6507c59
parentSet test to NULL when appropriate (diff)
downloadsway-0e4df85ba1a931a812c441572f352090a934e6bc.tar.gz
sway-0e4df85ba1a931a812c441572f352090a934e6bc.tar.zst
sway-0e4df85ba1a931a812c441572f352090a934e6bc.zip
Fixed config loading
-rw-r--r--sway/config.c16
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[] = {
71}; 71};
72 72
73static char *get_config_path() { 73static char *get_config_path() {
74 char *home = strdup(getenv("HOME")); 74 char *home = getenv("HOME");
75 char *config = strdup(getenv("XDG_CONFIG_HOME")); 75 if (home) {
76 if (!config) { 76 home = strdup(getenv("HOME"));
77 const char *def = "/.config/sway"; 77 }
78 char *config = getenv("XDG_CONFIG_HOME");
79 if (config) {
80 config = strdup(getenv("XDG_CONFIG_HOME"));
81 } else if (home) {
82 const char *def = "/.config";
78 config = malloc(strlen(home) + strlen(def) + 1); 83 config = malloc(strlen(home) + strlen(def) + 1);
79 strcpy(config, home); 84 strcpy(config, home);
80 strcat(config, def); 85 strcat(config, def);
86 } else {
87 home = strdup("");
88 config = strdup("");
81 } 89 }
82 90
83 // Set up a temporary config for holding set variables 91 // Set up a temporary config for holding set variables