From b402bac6f49519770f84d3667012cfd636c910a9 Mon Sep 17 00:00:00 2001 From: Cem Keylan Date: Wed, 29 Sep 2021 00:42:23 +0300 Subject: grab_environment_configuration(): complexify download directory :) --- browser.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'browser.c') 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); -- cgit v1.2.3