Simplify XDG_CONFIG_HOME handling

This commit is contained in:
emersion 2019-01-19 08:36:09 +01:00
parent 52eeb9fc1e
commit d98ada0efd
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

15
main.c
View File

@ -882,18 +882,9 @@ static char *get_config_path(void) {
SYSCONFDIR "/swaylock/config", SYSCONFDIR "/swaylock/config",
}; };
if (!getenv("XDG_CONFIG_HOME")) { char *config_home = getenv("XDG_CONFIG_HOME");
char *home = getenv("HOME"); if (!config_home || config_home[0] == '\0') {
char *config_home = malloc(strlen(home) + strlen("/.config") + 1); config_paths[1] = "$HOME/.config/swaylock/config";
if (!config_home) {
swaylock_log(LOG_ERROR, "Unable to allocate $HOME/.config");
} else {
strcpy(config_home, home);
strcat(config_home, "/.config");
setenv("XDG_CONFIG_HOME", config_home, 1);
swaylock_log(LOG_DEBUG, "Set XDG_CONFIG_HOME to %s", config_home);
free(config_home);
}
} }
wordexp_t p; wordexp_t p;