summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2015-08-19 10:36:33 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2015-08-19 10:36:33 -0400
commit2d3bd3c74772e72ed6119549428150c7318fe456 (patch)
tree5fbd81bd3fa24583ee932b296f146340b6507c59
parentSet test to NULL when appropriate (diff)
parentFixed config loading (diff)
downloadsway-2d3bd3c74772e72ed6119549428150c7318fe456.tar.gz
sway-2d3bd3c74772e72ed6119549428150c7318fe456.tar.zst
sway-2d3bd3c74772e72ed6119549428150c7318fe456.zip
Merge pull request #86 from Luminarys/master
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