[dconf/wip/peruserprofile: 2/3] engine: if a dconf.profile file or link is placed in XDG_RUNTIME_DIR that takes precedence over othe



commit 7ac7a41687aa73fc3577043fde006f3d954c100e
Author: Alberto Ruiz <aruiz redhat com>
Date:   Tue Jul 14 21:32:52 2015 +0100

    engine: if a dconf.profile file or link is placed in XDG_RUNTIME_DIR that takes precedence over other 
profile files

 engine/dconf-engine-profile.c |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/engine/dconf-engine-profile.c b/engine/dconf-engine-profile.c
index d3163b5..932479a 100644
--- a/engine/dconf-engine-profile.c
+++ b/engine/dconf-engine-profile.c
@@ -224,6 +224,21 @@ dconf_engine_open_profile_file (const gchar *profile)
   return fp;
 }
 
+static FILE *
+dconf_engine_get_runtime_profile (void) {
+  gchar *filename;
+  FILE  *fp;
+
+  filename = g_build_filename (g_get_user_runtime_dir (), "dconf.profile", NULL);
+  fp = fopen (filename, "r");
+
+  if (fp == NULL)
+    g_debug ("Unable to open %s: %s", filename, g_strerror (errno));
+
+  g_free (filename);
+  return fp;
+}
+
 DConfEngineSource **
 dconf_engine_profile_open (const gchar *profile,
                            gint        *n_sources)
@@ -236,7 +251,10 @@ dconf_engine_profile_open (const gchar *profile,
 
   if (profile == NULL)
     {
-      file = dconf_engine_open_profile_file ("user");
+      file = dconf_engine_get_runtime_profile ();
+
+      if (file == NULL)
+        file = dconf_engine_open_profile_file ("user");
 
       /* Only in the case that no profile was specified do we use this
        * fallback.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]