summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCem Keylan <cem@ckyln.com>2021-09-29 00:42:23 +0300
committerCem Keylan <cem@ckyln.com>2021-09-29 00:42:23 +0300
commitb402bac6f49519770f84d3667012cfd636c910a9 (patch)
tree3717d8f6ae4a9874c89f1231d122f5e2f25c18bb
parent061c9b553bb2742682ea9b15dfe5a8f98ef90500 (diff)
downloadlariza-b402bac6f49519770f84d3667012cfd636c910a9.tar.gz
grab_environment_configuration(): complexify download directory :)
-rw-r--r--browser.c14
-rw-r--r--man1/lariza.111
2 files changed, 22 insertions, 3 deletions
diff --git a/browser.c b/browser.c
index 36876c4..307690e 100644
--- a/browser.c
+++ b/browser.c
@@ -681,7 +681,21 @@ grab_environment_configuration(void)
if (e != NULL)
accepted_language[0] = g_strdup(e);
+ /*
+ * Accept XDG_DOWNLOAD_DIR as a valid download directory if
+ * LARIZA_DOWNLOAD_DIR is not specifically set. Since the XDG user directory
+ * specification is extremely stupid, and depends on a certain xdg-user-dir
+ * binary, we do two runs for acquiring the XDG_DOWNLOAD_DIR. We look at the
+ * environment variables (which what this specification should have been),
+ * and use g_get_user_special_dir() if that fails.
+ */
e = g_getenv(__NAME_UPPERCASE__"_DOWNLOAD_DIR");
+ if (e == NULL)
+ e = g_getenv("XDG_DOWNLOAD_DIR");
+ if (e == NULL)
+ e = g_get_user_special_dir(G_USER_DIRECTORY_DOWNLOAD);
+ if (e == NULL)
+ e = g_build_filename(g_get_home_dir(), "Downloads", NULL);
if (e != NULL)
download_dir = g_strdup(e);
diff --git a/man1/lariza.1 b/man1/lariza.1
index 3b169d1..b40c24b 100644
--- a/man1/lariza.1
+++ b/man1/lariza.1
@@ -35,9 +35,14 @@ In HTTP requests, WebKit sets the
header to this value. Defaults to
.Sy en-US .
.It Sy LARIZA_DOWNLOAD_DIR
-All downloads are automatically stored in this directory. This variable defaults
-to
-.Pa /var/tmp .
+All downloads are automatically stored in this directory. If this variable,
+doesn't exist,
+.Nm
+will try to form a directory using the
+.Ev XDG_DOWNLOAD_DIR
+specification, and fallback to
+.Pa /var/tmp
+if it fails.
.It Sy LARIZA_ENABLE_CONSOLE_TO_STDOUT
Enable writing WebKit console messages to stdout.
.It Sy LARIZA_FIFO_SUFFIX