From 9eb212cb910e28fe75ca0c102aafd2afbd4e6637 Mon Sep 17 00:00:00 2001 From: nullgemm Date: Sat, 1 Feb 2020 19:01:51 +0100 Subject: [PATCH] put xauthority file in XDG_CONFIG if specified --- src/login.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/login.c b/src/login.c index 361df01..1cabf63 100644 --- a/src/login.c +++ b/src/login.c @@ -304,10 +304,10 @@ void remove_utmp_entry(struct utmp *entry) { endutent(); } -void xauth(const char* display_name, const char* shell, const char* home) +void xauth(const char* display_name, const char* shell, const char* dir) { char xauthority[256]; - snprintf(xauthority, 256, "%s/%s", home, ".lyxauth"); + snprintf(xauthority, 256, "%s/%s", dir, ".lyxauth"); setenv("XAUTHORITY", xauthority, 1); FILE* fp = fopen(xauthority, "ab+"); @@ -344,7 +344,16 @@ void xorg( const char* desktop_cmd) { // generate xauthority file - xauth(display_name, pwd->pw_shell, pwd->pw_dir); + const char* xauth_dir; + + xauth_dir = getenv("XDG_CONFIG_HOME"); + + if ((xauth_dir == NULL) || (*xauth_dir == '\0')) + { + xauth_dir = pwd->pw_dir; + } + + xauth(display_name, pwd->pw_shell, xauth_dir); // start xorg pid_t pid = fork();