Ubuntu: How to save GNOME settings in a file?


I save my configuration in a Git repository to restore it easily later.

Recently, I stumbled upon an issue where needed to change GNOME settings with the gsettings command.

Is there a way to save these settings in a file that could be symlinked or copied in a predefined location expected by GNOME? I would prefer a method where I don't need to write a script to call gsettings.


GNOME settings are generally stored via the GSettings API, which is an implementation of the DConf specification. This stores the settings in a binary database, which should not be replaced while logged in.

Instead, the settings need to be exported and then loaded in again.

You can use dconf dump / > dconf-settings.ini to dump the settings to an INI file, and then use cat dconf-settings.ini > dconf load / to load those settings back in. You can replace the / with a specific path to limit what settings are dumped and loaded. See man dconf for more details there.

If you want to simply set a single key, rather than whole paths, it would be better to use gsettings for this, with gsettings get and gsettings set in a script.


See man 7 dconf:

KEY FILES     To facilitate system configuration with a text editor, dconf can     populate databases from plain text keyfiles. For any given system     database, keyfiles can be placed into the /etc/dconf/db/database.d/     directory. The keyfiles contain groups of settings as follows:           # Some useful default settings for our site           [system/proxy/http]         host=''         enabled=true           [org/gnome/desktop/background]         picture-uri='file:///usr/local/rupert-corp/company-wallpaper.jpeg'       After changing keyfiles, the database needs to be updated with the     dconf(1) tool.  

If you just need to have GNOME pick up settings from a file without scripting, this might be the simplest way, but it needs administrator access for creating the key file.

The other option is to save the binary dconf database itself, but that's not a good option for use with Git as version control. The database is typically located in $XDG_CONFIG_HOME/dconf (i.e., ~/.config/dconf by default). See section on PROFILES in the manpage.

The manpage also says:

   The binary database format that dconf uses by default is not suitable     for use on NFS, where mmap does not work well. To handle this common     use case, dconf can be configured to place its binary database in     XDG_RUNTIME_DIR (which is guaranteed to be local, but non-persistent)     and synchronize it with a plain text keyfile in the users home     directory.  

But it's not exactly clear how to do this without scripting.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »