mpd uses some additional files to work, such as pid_file, state_file,
db_file, etc. when running mpd as non-root user, it is often that those
files end in ~/.mpd

in that case, we end up with 2 entries in a user's home, .mpdconf and
.mpd - which clutters homedirs.

this patch allows ~/.mpd/mpd.conf as an alternative to ~/.mpdconf,
allowing for a cleaner homedir
---
 INSTALL        |    5 +++--
 doc/mpd.conf.5 |    4 ++--
 src/cmdline.c  |   23 +++++++++++++++--------
 3 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/INSTALL b/INSTALL
index cb58a5c..0847805 100644
--- a/INSTALL
+++ b/INSTALL
@@ -162,8 +162,9 @@ Run
 
 $ mpd <config file>
 
-First default is ~/.mpdconf then /etc/mpd.conf. If neither of these exist
-a mpd configuration file must be specified at runtime. A
+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.
 
 A sample config file is included with the source of MPD, mpdconf.example.
 
diff --git a/doc/mpd.conf.5 b/doc/mpd.conf.5
index cced775..0440dda 100644
--- a/doc/mpd.conf.5
+++ b/doc/mpd.conf.5
@@ -3,8 +3,8 @@
 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 and then in
-\fB/etc/mpd.conf\fP.
+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.
 
 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/cmdline.c b/src/cmdline.c
index 48c1e87..554119c 100644
--- a/src/cmdline.c
+++ b/src/cmdline.c
@@ -33,7 +33,8 @@
 #include <stdlib.h>
 
 #define SYSTEM_CONFIG_FILE_LOCATION    "/etc/mpd.conf"
-#define USER_CONFIG_FILE_LOCATION      ".mpdconf"
+#define USER_CONFIG_FILE_LOCATION1     ".mpdconf"
+#define USER_CONFIG_FILE_LOCATION2     ".mpd/mpd.conf"
 
 G_GNUC_NORETURN
 static void version(void)
@@ -134,16 +135,22 @@ void parseOptions(int argc, char **argv, Options *options)
 
        if (argc <= 1) {
                /* default configuration file path */
-               char *path;
-
-               path = g_build_filename(g_get_home_dir(),
-                                       USER_CONFIG_FILE_LOCATION, NULL);
-               if (g_file_test(path, G_FILE_TEST_IS_REGULAR))
-                       readConf(path);
+               char *path1;
+               char *path2;
+
+               path1 = g_build_filename(g_get_home_dir(),
+                                       USER_CONFIG_FILE_LOCATION1, NULL);
+               path2 = g_build_filename(g_get_home_dir(),
+                                       USER_CONFIG_FILE_LOCATION2, NULL);
+               if (g_file_test(path1, G_FILE_TEST_IS_REGULAR))
+                       readConf(path1);
+        else if (g_file_test(path2, G_FILE_TEST_IS_REGULAR))
+                       readConf(path2);
                else if (g_file_test(SYSTEM_CONFIG_FILE_LOCATION,
                                     G_FILE_TEST_IS_REGULAR))
                        readConf(SYSTEM_CONFIG_FILE_LOCATION);
-               g_free(path);
+               g_free(path1);
+               g_free(path2);
        } else if (argc == 2) {
                /* specified configuration file */
                readConf(argv[1]);
-- 
1.6.0.5


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team

Reply via email to