How do I change dconf keys without a gui (for a post-install script)?

I have installed dconf-tools. In this case I am manipulating the display of a name in the panel on the session indicator.

I can change this in dconf-editor gui with no problem, I go to apps/indicator-session, and untick show-real-name-on-panel.

However, I have also tried to toggle it just using dconf at the command line:

dconf write /com/canonical/indicator/session/show-real-name-on-panel false

After rebooting, the panel is unchanged, and the key in the dconf-editor is unchanged as well.

Moreover, trying to update the dconf database via the terminal yields an error:

$ dconf update
fatal: Error opening directory '/etc/dconf/db': No such file or directory

From my experience it seems as though dconf and dconf-editor have no relationship, so I just wonder what I am doing wrong.

If I can get this figured out, I want to just place the command in a bash script to run the next time I have to do a clean install for an upgrade*. I do a lot of tweaks in 6 months and I just want to automate as much as possible from now on.

  • Slightly off-topic: the distribution upgrade mechanism has never worked without a hitch for me; I tried it going from 11.04 to 11.10 as well.

You can use the gsettings tool.

gsettings set com.canonical.indicator.session show-real-name-on-panel false

The following worked for me on Ubuntu 14.04:

dconf write /org/gnome/gnome-session/auto-save-session true

The value did change and stayed changed after reboot. I had another problem that the windows weren't saved but that's a whole different issue.


dconf dump + load mass export and restore

  1. Dump all settings to a file:

    dconf dump / >~/.config/dconf/user.conf
    
  2. Open that file on a text editor and select the settings that you care about:

    editor ~/.config/dconf/user.conf
    

    If you use Vim, you will want this syntax highlight.

  3. If you don't know the name of the setting, but know how to modify it from a GUI like unity-control-center, run:

    dconf watch /
    

    and then modify them. The exact setting will then appear on the terminal.

  4. When you want to restore those settings, run:

    dconf load / <~/.config/dconf/user.conf
    
  5. Git track the config file to never lose it. homeshick is my current favorite method.

Tested on Ubuntu 15.10. Tip adapted from: http://catern.com/2014/12/21/plain-text-configuration-gnome.html


It seems (at least in 15.10) that there are some things (specifically compiz) which only store config at the dconf layer and can't be set via gsettings. It's possible this affects other config paths, but probably unlikely - since compiz is at a lower layer than unity I'm not surprised it behaves differently.

For example, this will work:

dconf write /org/compiz/profiles/unity/plugins/core/outputs "['3200x1800+288+2160', '3840x2160+0+0']"

while this will not:

gsettings set org.compiz.profiles.unity.plugins.core outputs "['3200x1800+288+2160', '3840x2160+0+0']"
# No such schema 'org.compiz.profiles.unity.plugins.core'

Now if only I could figure out how to reload compiz without crashing everything...