Merge pull request #26 from swaywm/simplify-config-path

Simplify XDG_CONFIG_HOME handling
This commit is contained in:
Brian Ashworth 2019-01-19 02:54:49 -05:00 committed by GitHub
commit 4e72a36edc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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;