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.
This commit is contained in:
Cavernosa 2022-08-08 01:40:18 +00:00 committed by GitHub
parent 0a798831fe
commit 8610442c78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 3 deletions

View File

@ -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