How to save GNOME settings in a file?
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.
Here a little correction for "Dobey" commands :
It's ok to save all donf settings like this :
dconf dump / > dconf-settings.ini
But you have to restore them like that ! :
dconf load / < dconf-settings.ini
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='172.16.0.1'
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.