summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2011-12-12 22:20:16 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2011-12-12 22:22:35 +0100
commit83ac3b4673de071651c8b8c57095e4de6d229ef8 (patch)
tree256f7cab59ba376b89c400aa038d3bd9ed143447
parent88bfed02ebb4d311836a84291cfe5b773eaefc46 (diff)
downloadpa-sink-ctl-83ac3b4673de071651c8b8c57095e4de6d229ef8.tar.gz
pa-sink-ctl-83ac3b4673de071651c8b8c57095e4de6d229ef8.tar.bz2
pa-sink-ctl-83ac3b4673de071651c8b8c57095e4de6d229ef8.zip
Read config from config- not data-dirs
glib provides no wrapper, so we have to loop ourselves over system and user dirs.
-rw-r--r--src/config.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/config.c b/src/config.c
index e24ece0..73bebe2 100644
--- a/src/config.c
+++ b/src/config.c
@@ -64,18 +64,29 @@ destroy_priority(gpointer data)
int
config_init(struct config *cfg)
{
- GError *error = NULL;
+ /* FIXME: Not a nicer method available in glib? */
+ const gchar *home_dirs[] = { g_get_user_config_dir(), NULL };
+ const gchar * const * dirs_array[] = { home_dirs, g_get_system_config_dirs() };
+ GError *error;
+ int i;
memset(cfg, 0, sizeof *cfg);
cfg->keyfile = g_key_file_new();
cfg->priorities = NULL;
- if (!g_key_file_load_from_data_dirs(cfg->keyfile,
- "pa-sink-ctl/config.ini",
- NULL, G_KEY_FILE_NONE, &error)
- && error) {
- g_printerr("Failed to open config file: %s\n", error->message);
- return -1;
+ for (i = 0; i < G_N_ELEMENTS(dirs_array); ++i) {
+ error = NULL;
+ if (g_key_file_load_from_dirs(cfg->keyfile,
+ "pa-sink-ctl/config.ini",
+ (const gchar **) dirs_array[i],
+ NULL, G_KEY_FILE_NONE, &error)
+ && !error)
+ break;
+ }
+ if (error) {
+ g_printerr("Failed to open config file: %s\n",
+ error->message);
+ return -1;
}
if (parse_priorities(cfg) < 0)