DConf Overview



dconf is a simple key/value storage system. dconf has a partial client/server architecture. It uses D-Bus. The server is only involved in writes (and is not activated in the user session until the user modifies a preference). The list of paths that each process is watching is stored within the D-Bus daemon itself (as D-Bus signal match rules).

A profile is a list of configuration databases that dconf consults to find the value for a key. The user’s personal database always takes the highest priority, followed by the system databases in the order prescribed by the profile. Profile file is stored in /etc/dconf/profile/user. It defines 3 databases:

Adding an app

According to mer. But, harbour doesn’t allow this

Create a key file with your defaults in /etc/dconf/db/nemo.d/<package-name>.txt:

miValue='a value'

Call dconf-update via a oneshot (%{_bindir}/add-oneshot dconf-update) in %post.

DConf command line utility

[nemo@SailfishEmul ~]$ dconf help
  dconf COMMAND [ARGS...]

  help              Show this information
  read              Read the value of a key
  list              List the contents of a dir
  write             Change the value of a key
  reset             Reset the value of a key or dir
  update            Update the system databases
  watch             Watch a path for changes
  dump              Dump an entire subpath to stdout
  load              Populate a subpath from stdin

The basic ussage is simple: * Reading values: dconf read /my/app/key the value will be printed. * Writing values: dconf write /my/app/key <value>, <value> is the value that is going to be saved on that key. Remember, that it has to have GVariant format. Ie, if you want to write a string: dconf write /my/app/key '"this is the value"' (yes, it has quotes in the quoted value). For booleans <value> will be true or false.

Using dconf in python through GSettings

This is only intended if you are developing a python app which is allowed in harbour.

In Qt/C++ you are encorage to use the MGConfItem provided by the nemomobile/mlite package, and in qml the nemomobile/configuration qml plugin, although it has not been harbour-whitelisted). The problem of using python is that there are not bindings. The work arround is using GSettings of the gi.repository packages which uses dconf as backend.

In order to use GSettings a configuration schema has to be declared and compiled.

Generate <app>.gschema.xml -> /usr/share/glib-2.0/schemas/

Harbour doesn’t allow to write files in /usr/share/glib-2.0/schemas. If targeting harbour, a workaround could be writing the file in /usr/share/<HARBOUR_APP_NAME> compile the file, and in runtime change XDG_DATA_DIRS in order to make GSettings to look for the custom schema.

id is the schema id, while path is the dconf key.

<?xml version="1.0" encoding="UTF-8"?>
  <schema id="apps.harbour-my-nice-app" path="/apps/harbour-my-nice-app/">
    <key type="s" name="miValue">
      <default>'a value'</default>
      <summary>My string value</summary>
      <description>This is an example of a string setting.</description>
    <key type="i" name="anotherValue">
      <summary>My number value</summary>
      <description>This is an example of a number setting.</description>
    <key type="b" name="boolValue">
      <summary>My bool value</summary>
      <description>This is an example of a bool setting.</description>

Compile Schemas

[root@SailfishEmul ~]# glib-compile-schemas /usr/share/glib-2.0/schemas/

Example code:

from gi.repository import Gio

if __name__ == "__main__":
    gsettings = Gio.Settings.new("apps.harbour-my-nice-app")
    gsettings.set_string("miValue", "another value")

See the Gio.Settings documentation for full information about how to set/get values. Remember that if you change values, .apply() method must be called!.

You can check that both the python script and dconf read command utility return the same values for the same paths.

Using dconf in QML org.nemomobile.configuration


The plugin has to be included: import org.nemomobile.configuration 1.0. It provides two components:


ApplicationWindow {
    initialPage: Component {
        Page {
            ConfigurationValue {
                id: configurationValue

            SilicaFlickable {
                anchors.fill: parent
                contentHeight: column.height

                Column {
                    id: column
                    width: parent.width
                    height: childRect.height

                    PageHeader { title: "Qml DConf Client" }

                    TextField {
                        id: key
                        width: parent.width
                        inputMethodHints: Qt.ImhNoPredictiveText
                        label: "Key"
                        placeholderText: "Key"
                        focus: true
                        EnterKey.onClicked: {
                            configurationValue.key = key.text
                            value.text = configurationValue.value

                    TextField {
                        id: value
                        width: parent.width
                        inputMethodHints: Qt.ImhNoPredictiveText
                        label: "Value"
                        placeholderText: "Value"
                        EnterKey.onClicked: {
                            configurationValue.value = value.text

In this example, when the key field is setted and the enter key is hit, the value field will be filled with the dconf value. If in the value TextField is chaged, and the enter key is pressed, the value will be saved.

Download example.