Hello,

I wrote a little patch for searching the config file under the XDG_CONFIG_HOME
directory too.

It will look for "$XDG_CONFIG_HOME/mpd/mpd.conf", similar to where mpd looks for
the file under Windows.

---
 INSTALL             | 6 +++---
 doc/mpd.1           | 4 ++--
 doc/mpd.conf.5      | 5 +++--
 src/CommandLine.cxx | 8 +++++++-
 4 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/INSTALL b/INSTALL
index 185798a..4258d29 100644
--- a/INSTALL
+++ b/INSTALL
@@ -196,9 +196,9 @@ Run
 
 $ mpd <config file>
 
-First default is ~/.mpdconf then ~/.mpd/mpd.conf then /etc/mpd.conf. If
-neither of these exist a mpd configuration file must be specified at
-runtime.
+First default is $XDG_CONFIG_HOME/mpd/mpd.conf then ~/.mpdconf then
+~/.mpd/mpd.conf then /etc/mpd.conf. If neither of these exist a mpd
+configuration file must be specified at runtime.
 
 A sample config file is included with the source of MPD, mpdconf.example.
 
diff --git a/doc/mpd.1 b/doc/mpd.1
index 49a3e1b..ddeb2f5 100644
--- a/doc/mpd.1
+++ b/doc/mpd.1
@@ -12,8 +12,8 @@ stores info about all available music, and this info can be 
easily searched and
 retrieved.  Player control, info retrieval, and playlist management can all be
 managed remotely.
 
-MPD searches for a config file in \fB~/.mpdconf\fP then \fB/etc/mpd.conf\fP or
-uses CONF_FILE.
+MPD searches for a config file in \fB$XDG_CONFIG_HOME/mpd/mpd.conf\fP then
+\fB~/.mpdconf\fP then \fB/etc/mpd.conf\fP or uses CONF_FILE.
 
 Read more about MPD at <\fBhttp://www.musicpd.org/\fP>.
 .SH OPTIONS
diff --git a/doc/mpd.conf.5 b/doc/mpd.conf.5
index 62f5565..d441c0d 100644
--- a/doc/mpd.conf.5
+++ b/doc/mpd.conf.5
@@ -3,8 +3,9 @@
 mpd.conf \- Music Player Daemon configuration file
 .SH DESCRIPTION
 \fBmpd.conf\fP is the configuration file for mpd(1).  If not specified on the
-command line, MPD first searches for it at \fB~/.mpdconf\fP then at
-\fB~/.mpd/mpd.conf\fP and then in \fB/etc/mpd.conf\fP.
+command line, MPD first searches for it at \fB$XDG_CONFIG_HOME/mpd/mpd.conf\fP
+then at \fB~/.mpdconf\fP then at \fB~/.mpd/mpd.conf\fP and then in
+\fB/etc/mpd.conf\fP.
 
 Lines beginning with a "#" character are comments.  All other non-empty lines
 specify parameters and their values.  These lines contain the parameter name
diff --git a/src/CommandLine.cxx b/src/CommandLine.cxx
index a62ea37..89575a1 100644
--- a/src/CommandLine.cxx
+++ b/src/CommandLine.cxx
@@ -54,6 +54,7 @@
 #else /* G_OS_WIN32 */
 #define USER_CONFIG_FILE_LOCATION1     ".mpdconf"
 #define USER_CONFIG_FILE_LOCATION2     ".mpd/mpd.conf"
+#define USER_CONFIG_FILE_LOCATION_XDG  "mpd/mpd.conf"
 #endif
 
 static GQuark
@@ -219,7 +220,12 @@ parse_cmdline(int argc, char **argv, struct options 
*options,
                                return ReadConfigFile(path, error_r);
                }
 #else /* G_OS_WIN32 */
-               Path path = PathBuildChecked(Path::FromUTF8(g_get_home_dir()),
+               Path path = 
PathBuildChecked(Path::FromUTF8(g_get_user_config_dir()),
+                                            USER_CONFIG_FILE_LOCATION_XDG);
+               if (!path.IsNull() && FileExists(path))
+                       return ReadConfigFile(path, error_r);
+
+               path = PathBuildChecked(Path::FromUTF8(g_get_home_dir()),
                                             USER_CONFIG_FILE_LOCATION1);
                if (!path.IsNull() && FileExists(path))
                        return ReadConfigFile(path, error_r);
-- 
1.8.3.2

Attachment: signature.asc
Description: Digital signature

------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team

Reply via email to