From d98ada0efde854e159b3938737e23a0a8ab69873 Mon Sep 17 00:00:00 2001 From: emersion Date: Sat, 19 Jan 2019 08:36:09 +0100 Subject: [PATCH] Simplify XDG_CONFIG_HOME handling --- main.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/main.c b/main.c index d3921d5..60f1a96 100644 --- a/main.c +++ b/main.c @@ -882,18 +882,9 @@ static char *get_config_path(void) { SYSCONFDIR "/swaylock/config", }; - if (!getenv("XDG_CONFIG_HOME")) { - char *home = getenv("HOME"); - char *config_home = malloc(strlen(home) + strlen("/.config") + 1); - 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); - } + char *config_home = getenv("XDG_CONFIG_HOME"); + if (!config_home || config_home[0] == '\0') { + config_paths[1] = "$HOME/.config/swaylock/config"; } wordexp_t p;