From d8ba1110106dd061f513661cdcc7f9328c5cd3bf Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Sun, 7 May 2023 14:47:43 +0200 Subject: [PATCH] [home] Restored ELINKS_CONFDIR . Refs #199 --- doc/elinks.1.txt | 5 +++++ doc/man/man1/elinks.1.in | 6 ++++++ src/config/home.c | 14 +++++++++++--- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/doc/elinks.1.txt b/doc/elinks.1.txt index d473e790..b6b45647 100644 --- a/doc/elinks.1.txt +++ b/doc/elinks.1.txt @@ -56,6 +56,11 @@ EDITOR:: The program to use for external editor (when editing textareas). +ELINKS_CONFDIR:: + + If set the location of the directory containing configuration files. + If not set see below. + XDG_CONFIG_HOME:: The location of the directory containing configuration files. If set diff --git a/doc/man/man1/elinks.1.in b/doc/man/man1/elinks.1.in index 03281a4f..849eb654 100644 --- a/doc/man/man1/elinks.1.in +++ b/doc/man/man1/elinks.1.in @@ -324,6 +324,12 @@ The path to the users home directory\&. Used when expanding ~/\&. .RE .PP +ELINKS_CONFDIR +.RS 4 +If set the location of the directory containing configuration files. +If not set see below. +.RE +.PP XDG_CONFIG_HOME .RS 4 If set the location of the directory containing configuration files diff --git a/src/config/home.c b/src/config/home.c index 17a8acaa..d6c83d90 100644 --- a/src/config/home.c +++ b/src/config/home.c @@ -91,13 +91,21 @@ get_xdg_config_home(void) if (xdg_config_home) { return xdg_config_home; } + char *config_dir = NULL; + char *elinks_confdir = getenv("ELINKS_CONFDIR"); + char *pa = get_cmd_opt_str("config-dir"); + + if (elinks_confdir && *elinks_confdir && (!pa || !*pa)) { + xdg_config_home = test_confdir(NULL, elinks_confdir, NULL); + + if (xdg_config_home) goto end; + } char *g_xdg_config_home = getenv("XDG_CONFIG_HOME"); char *home; - char *config_dir = NULL; if (g_xdg_config_home && *g_xdg_config_home) { xdg_config_home = test_confdir(g_xdg_config_home, - get_cmd_opt_str("config-dir"), + pa, N_("Commandline options -config-dir set to %s, " "but could not create directory %s.")); if (xdg_config_home) { @@ -122,7 +130,7 @@ get_xdg_config_home(void) return NULL; } xdg_config_home = test_confdir(config_dir, - get_cmd_opt_str("config-dir"), + pa, N_("Commandline options -config-dir set to %s, " "but could not create directory %s.")); if (xdg_config_home) {