dconf: use text-based key file and dconf update
authorDaiki Ueno <ueno@unixuser.org>
Sun, 20 May 2012 06:01:01 +0000 (15:01 +0900)
committerDaiki Ueno <ueno@unixuser.org>
Sun, 20 May 2012 06:01:01 +0000 (15:01 +0900)
BUG=none
TEST=manually

Review URL: https://codereview.appspot.com/6215062

data/dconf/Makefile.am
data/dconf/make-dconf-override-db.sh

index daea896..54861a7 100644 (file)
@@ -32,6 +32,7 @@ EXTRA_DIST = \
        $(gsettings_schemas_in_files) \
        make-dconf-override-db.sh \
        profile/ibus \
+       00-upstream-settings \
        $(NULL)
 
 DISTCLEANFILES = \
@@ -40,23 +41,26 @@ DISTCLEANFILES = \
 
 MAINTAINERCLEANFILES = \
        $(gsettings_schemas_in_files) \
+       00-upstream-settings \
        $(NULL)
 
-CLEANFILES = \
-       db/ibus \
-       $(NULL)
+dconfprofiledir = $(sysconfdir)/dconf/profile
+dconfprofile_DATA = profile/ibus
 
-dconfprofiledir = $(sysconfdir)/dconf
-nobase_dconfprofile_DATA = db/ibus profile/ibus
+dconfdbdir = $(sysconfdir)/dconf/db/ibus.d
+dconfdb_DATA = 00-upstream-settings
 
 org.freedesktop.ibus.gschema.xml.in: $(top_srcdir)/data/ibus.schemas.in
        $(AM_V_GEN) gsettings-schema-convert --force --gconf --xml \
                --schema-id "org.freedesktop.ibus" \
                --output $@ $<
 
-db/ibus: $(srcdir)/make-dconf-override-db.sh $(gsettings_SCHEMAS)
+00-upstream-settings: $(srcdir)/make-dconf-override-db.sh $(gsettings_SCHEMAS)
        @$(MKDIR_P) db
-       $(AM_V_GEN) $(srcdir)/make-dconf-override-db.sh $@ || \
+       $(AM_V_GEN) $(srcdir)/make-dconf-override-db.sh $@ || \
                { rc=$$?; $(RM) -rf $@; exit $$rc; }
 
+install-data-hook:
+       dconf update
+
 -include $(top_srcdir)/git.mk
index 0d8456b..49a6df9 100755 (executable)
@@ -15,17 +15,32 @@ trap 'rm -rf $TMPDIR; kill $DBUS_SESSION_BUS_PID' ERR
 # in case that schema is not installed on the system
 glib-compile-schemas --targetdir "$GSETTINGS_SCHEMA_DIR" "$PWD"
 
-gsettings list-recursively org.freedesktop.ibus.general | \
-while read schema key val; do
-    gsettings set "$schema" "$key" "$val"
+cat <<EOF
+# This file is a part of the IBus packaging and should not be changed.
+#
+# Instead create your own file next to it with a higher numbered prefix,
+# and run
+#
+#       dconf update
+#
+EOF
+
+# Loop over top level schemas since "gsettings list-recursively" only
+# looks for direct children.
+schemas="org.freedesktop.ibus.general org.freedesktop.ibus.panel"
+current_schema=
+for schema in $schemas; do
+  gsettings list-recursively $schema | \
+  while read schema key val; do
+    if test "$schema" != "$current_schema"; then
+      echo
+      echo $schema | sed 's/org\.freedesktop\(.*\)/[desktop\1]/' | tr '.' '/'
+      current_schema="$schema"
+    fi
+    echo "$key=$val"
+  done
 done
 
-gsettings list-recursively org.freedesktop.ibus.panel | \
-while read schema key val; do
-    gsettings set "$schema" "$key" "$val"
-done
-
-mv $XDG_CONFIG_HOME/dconf/user "$1"
 rm -rf $TMPDIR
 
 kill $DBUS_SESSION_BUS_PID