mirror of
https://github.com/swaywm/sway.git
synced 2024-11-22 16:01:27 +00:00
config: do not set $XDG_CONFIG_HOME if unset or empty
Instead redefine the config paths to use the default $HOME/.config
This commit is contained in:
parent
de66ed4beb
commit
bca21ee0cf
|
@ -316,28 +316,16 @@ static char *get_config_path(void) {
|
||||||
SYSCONFDIR "/i3/config",
|
SYSCONFDIR "/i3/config",
|
||||||
};
|
};
|
||||||
|
|
||||||
char *curr_config_home = getenv("XDG_CONFIG_HOME");
|
char *config_home = getenv("XDG_CONFIG_HOME");
|
||||||
if (!curr_config_home || !*curr_config_home) {
|
if (!config_home || !*config_home) {
|
||||||
char *home = getenv("HOME");
|
config_paths[1] = "$HOME/.config/sway/config";
|
||||||
char *config_home = malloc(strlen(home) + strlen("/.config") + 1);
|
config_paths[3] = "$HOME/.config/i3/config";
|
||||||
if (!config_home) {
|
|
||||||
wlr_log(WLR_ERROR, "Unable to allocate $HOME/.config");
|
|
||||||
} else {
|
|
||||||
strcpy(config_home, home);
|
|
||||||
strcat(config_home, "/.config");
|
|
||||||
setenv("XDG_CONFIG_HOME", config_home, 1);
|
|
||||||
wlr_log(WLR_DEBUG, "Set XDG_CONFIG_HOME to %s", config_home);
|
|
||||||
free(config_home);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wordexp_t p;
|
for (size_t i = 0; i < sizeof(config_paths) / sizeof(char *); ++i) {
|
||||||
char *path;
|
wordexp_t p;
|
||||||
|
if (wordexp(config_paths[i], &p, WRDE_UNDEF) == 0) {
|
||||||
int i;
|
char *path = strdup(p.we_wordv[0]);
|
||||||
for (i = 0; i < (int)(sizeof(config_paths) / sizeof(char *)); ++i) {
|
|
||||||
if (wordexp(config_paths[i], &p, 0) == 0) {
|
|
||||||
path = strdup(p.we_wordv[0]);
|
|
||||||
wordfree(&p);
|
wordfree(&p);
|
||||||
if (file_exists(path)) {
|
if (file_exists(path)) {
|
||||||
return path;
|
return path;
|
||||||
|
@ -346,7 +334,7 @@ static char *get_config_path(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL; // Not reached
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool load_config(const char *path, struct sway_config *config,
|
static bool load_config(const char *path, struct sway_config *config,
|
||||||
|
|
Loading…
Reference in a new issue