[PATCH 1/2] cli: looking for config file in $XDG_CONFIG_HOME

sh!zeeg shizeeque at gmail.com
Wed Mar 14 05:43:20 PDT 2018


According to XDG Base Directory Specification
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
configuration files should be stored in $XDG_CONFIG_HOME which
defaulted to $HOME/.config/
---
 notmuch-config.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/notmuch-config.c b/notmuch-config.c
index e1b16609..7651c912 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -293,7 +293,7 @@ out:
 /* Open the named notmuch configuration file. If the filename is NULL,
  * the value of the environment variable $NOTMUCH_CONFIG will be used.
  * If $NOTMUCH_CONFIG is unset, the default configuration file
- * ($HOME/.notmuch-config) will be used.
+ * ($XDG_CONFIG_HOME/notmuch/config) will be used.
  *
  * If any error occurs, (out of memory, or a permission-denied error,
  * etc.), this function will print a message to stderr and return
@@ -358,8 +358,10 @@ notmuch_config_open (void *ctx,
 	config->filename = talloc_strdup (config, filename);
     } else if ((notmuch_config_env = getenv ("NOTMUCH_CONFIG"))) {
 	config->filename = talloc_strdup (config, notmuch_config_env);
+    } else if ((notmuch_config_env = getenv ("XDG_CONFIG_HOME"))) {
+	config->filename = talloc_strdup (config, notmuch_config_env);
     } else {
-	config->filename = talloc_asprintf (config, "%s/.notmuch-config",
+	config->filename = talloc_asprintf (config, "%s/.config/notmuch/config",
 					    getenv ("HOME"));
     }
 
-- 
2.16.2



More information about the notmuch mailing list