Improvements on the last commit

Initially assigning `lyxauth` instead of `.lyxauth` so theres no need for a bunch of `else`s
Using `.config` instead of `.config/ly` just like the XDG_CONFIG_HOME fallback, which also makes more sense.
This commit is contained in:
Cavernosa 2022-08-08 03:13:45 +00:00 committed by GitHub
parent 8610442c78
commit 5787c26e69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 11 deletions

View File

@ -302,7 +302,7 @@ void remove_utmp_entry(struct utmp *entry) {
void xauth(const char* display_name, const char* shell, char* pwd) void xauth(const char* display_name, const char* shell, char* pwd)
{ {
const char* xauth_file = ".lyxauth"; const char* xauth_file = "lyxauth";
char* xauth_dir = getenv("XDG_RUNTIME_DIR"); char* xauth_dir = getenv("XDG_RUNTIME_DIR");
if ((xauth_dir == NULL) || (*xauth_dir == '\0')) if ((xauth_dir == NULL) || (*xauth_dir == '\0'))
{ {
@ -310,24 +310,16 @@ void xauth(const char* display_name, const char* shell, char* pwd)
if ((xauth_dir == NULL) || (*xauth_dir == '\0')) if ((xauth_dir == NULL) || (*xauth_dir == '\0'))
{ {
xauth_dir = strdup(pwd); xauth_dir = strdup(pwd);
strcat(xauth_dir, "/.config/ly"); strcat(xauth_dir, "/.config");
struct stat sb; struct stat sb;
stat(xauth_dir, &sb); stat(xauth_dir, &sb);
if (!S_ISDIR(sb.st_mode)) if (!S_ISDIR(sb.st_mode))
{ {
xauth_dir = pwd; xauth_dir = pwd;
// xauth_file is already assigned correctly xauth_file = ".lyxauth";
}
else
{
xauth_file = "lyxauth";
} }
} }
} }
else
{
xauth_file = "lyxauth";
}
// trim trailing slashes // trim trailing slashes
int i = strlen(xauth_dir) - 1; int i = strlen(xauth_dir) - 1;