From c4464b4406c9fa5adbfbb72ff52b681d8ed044dd Mon Sep 17 00:00:00 2001 From: maxice8 Date: Wed, 17 Apr 2019 11:31:21 -0300 Subject: try $XDG_CONFIG_HOME/mpd-notification.conf first Signed-off-by: Christian Hesse --- README.md | 3 ++- mpd-notification.c | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ddea491..fb93db8 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,8 @@ Configuration ------------- Configuration options can be read from a configuration file. `mpd` -tries to read `~/.config/mpd-notification.conf`, which is expected to +tries to read `${XDG_CONFIG_HOME}/mpd-notification.conf`, then +`~/.config/mpd-notification.conf`, which is expected to look like this: host = localhost diff --git a/mpd-notification.c b/mpd-notification.c index 19b2235..5888012 100644 --- a/mpd-notification.c +++ b/mpd-notification.c @@ -257,8 +257,12 @@ int main(int argc, char ** argv) { music_dir = getenv("XDG_MUSIC_DIR"); /* parse config file */ - if (chdir(getenv("HOME")) == 0 && access(".config/mpd-notification.conf", R_OK) == 0 && - (ini = iniparser_load(".config/mpd-notification.conf")) != NULL) { + if (chdir(getenv("XDG_CONFIG_HOME")) == 0 && access("mpd-notification.conf", R_OK) == 0) { + ini = iniparser_load("mpd-notification.conf"); + } else if (chdir(getenv("HOME")) == 0 && access(".config/mpd-notification.conf", R_OK) == 0) { + ini = iniparser_load(".config/mpd-notification.conf"); + } + if (ini != NULL) { file_workaround = iniparser_getboolean(ini, ":notification-file-workaround", file_workaround); mpd_host = iniparser_getstring(ini, ":host", mpd_host); mpd_port = iniparser_getint(ini, ":port", mpd_port); -- cgit v1.2.3-70-g09d2