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

Tomi Ollila tomi.ollila at iki.fi
Wed Mar 14 17:02:34 PDT 2018


On Wed, Mar 14 2018, shizeeque at gmail.com wrote:

> 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/

Interesting stuff -- IIRC we tried something like this like 5 years ago
... and now we've been discussing about other options ...

Anyway, this would break status quo and current users' environments,
and secondly it looks like all fails unless this /notmuch/ directory
in XDG_CONFIG_HOME / ~/.config exists.

Tomi


> ---
>  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