From 8610442c787925e425128851f8c386575e5bd9bc Mon Sep 17 00:00:00 2001 From: Cavernosa <42952107+Cavernosa@users.noreply.github.com> Date: Mon, 8 Aug 2022 01:40:18 +0000 Subject: [PATCH] Fix XDG Base Dirs implementation renamed `XDG_CONFIG_DIR` -> `XDG_CONFIG_HOME` added `.config/ly` as fallback as specified in the specification, and pwd as last resort. --- src/login.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/login.c b/src/login.c index e704022..69e9302 100644 --- a/src/login.c +++ b/src/login.c @@ -306,11 +306,22 @@ void xauth(const char* display_name, const char* shell, char* pwd) char* xauth_dir = getenv("XDG_RUNTIME_DIR"); if ((xauth_dir == NULL) || (*xauth_dir == '\0')) { - xauth_dir = getenv("XDG_CONFIG_DIR"); + xauth_dir = getenv("XDG_CONFIG_HOME"); if ((xauth_dir == NULL) || (*xauth_dir == '\0')) { - xauth_dir = pwd; - xauth_file = "lyxauth"; + xauth_dir = strdup(pwd); + strcat(xauth_dir, "/.config/ly"); + struct stat sb; + stat(xauth_dir, &sb); + if (!S_ISDIR(sb.st_mode)) + { + xauth_dir = pwd; + // xauth_file is already assigned correctly + } + else + { + xauth_file = "lyxauth"; + } } } else