put xauthority file in XDG_CONFIG if specified

This commit is contained in:
nullgemm
2020-02-01 19:01:51 +01:00
parent fa42781cb9
commit 9eb212cb91

View File

@@ -304,10 +304,10 @@ void remove_utmp_entry(struct utmp *entry) {
endutent(); 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]; char xauthority[256];
snprintf(xauthority, 256, "%s/%s", home, ".lyxauth"); snprintf(xauthority, 256, "%s/%s", dir, ".lyxauth");
setenv("XAUTHORITY", xauthority, 1); setenv("XAUTHORITY", xauthority, 1);
FILE* fp = fopen(xauthority, "ab+"); FILE* fp = fopen(xauthority, "ab+");
@@ -344,7 +344,16 @@ void xorg(
const char* desktop_cmd) const char* desktop_cmd)
{ {
// generate xauthority file // 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 // start xorg
pid_t pid = fork(); pid_t pid = fork();