mirror of
https://github.com/swaywm/sway.git
synced 2024-11-14 06:24:20 +01:00
swaynag: handle empty $XDG_CONFIG_HOME better
Set config path to fallback instead of setting $XDG_CONFIG_HOME
This commit is contained in:
parent
89ad3f2bbb
commit
8729c65311
@ -304,25 +304,15 @@ char *swaynag_get_config_path(void) {
|
|||||||
SYSCONFDIR "/swaynag/config",
|
SYSCONFDIR "/swaynag/config",
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!getenv("XDG_CONFIG_HOME")) {
|
char *config_home = getenv("XDG_CONFIG_HOME");
|
||||||
char *home = getenv("HOME");
|
if (!config_home || *config_home) {
|
||||||
char *config_home = malloc(strlen(home) + strlen("/.config") + 1);
|
config_paths[1] = "$HOME/.config/swaynag/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;
|
wordexp_t p;
|
||||||
char *path;
|
|
||||||
for (size_t i = 0; i < sizeof(config_paths) / sizeof(char *); ++i) {
|
for (size_t i = 0; i < sizeof(config_paths) / sizeof(char *); ++i) {
|
||||||
if (wordexp(config_paths[i], &p, 0) == 0) {
|
if (wordexp(config_paths[i], &p, 0) == 0) {
|
||||||
path = strdup(p.we_wordv[0]);
|
char *path = strdup(p.we_wordv[0]);
|
||||||
wordfree(&p);
|
wordfree(&p);
|
||||||
if (file_exists(path)) {
|
if (file_exists(path)) {
|
||||||
return path;
|
return path;
|
||||||
|
Loading…
Reference in New Issue
Block a user