aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJérôme Quelin <jquelin@gmail.com>2009-01-14 14:27:17 +0100
committerMax Kellermann <max@duempel.org>2009-01-14 14:31:55 +0100
commitae5517b0b3a01c4e3e678f77d85f30b7ac3f3273 (patch)
tree0e49bb5110d8110be0b4df17b27116eae8913130 /src
parent642b861526084658a7b10beb9cbb81000d23432d (diff)
downloadmpd-ae5517b0b3a01c4e3e678f77d85f30b7ac3f3273.tar.gz
mpd-ae5517b0b3a01c4e3e678f77d85f30b7ac3f3273.tar.xz
mpd-ae5517b0b3a01c4e3e678f77d85f30b7ac3f3273.zip
allow ~/.mpd/mpd.conf as alternate config file
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
Diffstat (limited to 'src')
-rw-r--r--src/cmdline.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/cmdline.c b/src/cmdline.c
index 48c1e87e6..14a22da34 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]);