First, Apps should not mess with dconf
Introduction from dconf project page:
dconf is a low-level configuration system. Its main purpose is to provide a backend to GSettings on platforms that don't already have configuration storage systems.
Where's the data stored? (Ref: https://wiki.gnome.org/Projects/dconf/SystemAdministrators)
A profile is a list of configuration databases. What it seems that Gnome & Unity use same profile.
$ cat /etc/dconf/profile/gdm
user-db:user
system-db:gdm
user-db:user: First database in the profile is read-write rw and it is created in the user's home directory.
$ file ~/.config/dconf/user
/home/sneetsher/.config/dconf/user: GVariant Database file, version 0
system-db:gdm: read-only
$ file /etc/dconf/db/gdm
/etc/dconf/db/gdm: GVariant Database file, version 0
dconf could bind a text style store in addition to GVariant Database from db.d/* folder. Example (Notice file path, so it is a part of system-db:gdm):
$ cat /etc/dconf/db/gdm.d/00-upstream-settings
# This file is part of the GDM packaging and should not be changed.
#
# Instead create your own file next to it with a higher numbered prefix,
# and run
#
# dconf update
#
[org/gnome/desktop/a11y/keyboard]
enable=true
[org/gnome/desktop/background]
show-desktop-icons=false
...
Schema Files: Relation between schema id & schema path (*.gschema.xml)
What is the schema XML file in the data/glib-2.0 folder of my Quickly application? by trent shows a nice example of using GSettings API in a Quickly application, and his conclusion based on his experience.
Back to Vino. Each application that uses GSsettings should define its schema's and should store/install them in /usr/share/glib-2.0/schemas/ (It's a glib directory):
$ dpkg -L vino | grep -i glib-2.0
/usr/share/glib-2.0
/usr/share/glib-2.0/schemas
/usr/share/glib-2.0/schemas/org.gnome.Vino.enums.xml
/usr/share/glib-2.0/schemas/org.gnome.Vino.gschema.xml
$ more /usr/share/glib-2.0/schemas/org.gnome.Vino.gschema.xml
<schemalist>
<schema id='org.gnome.Vino' path='/org/gnome/desktop/remote-access/'>
<key name='enabled' type='b'>
<summary>Enable remote access to the desktop</summary>
<description>
If true, allows remote access to the desktop via the RFB
protocol. Users on remote machines may then connect to the
desktop using a VNC viewer.
</description>
<default>false</default>
</key>
<key name='prompt-enabled' type='b'>
<summary>Prompt the user before completing a connection</summary>
<description>
If true, remote users accessing the desktop are not allowed
access until the user on the host machine approves the
connection. Recommended especially when access is not password
protected.
</description>
<default>true</default>
</key>
...
If you noticed, The schema is defined with an id and a path. The schema file name follows the id value.
<schema id='org.gnome.Vino' path='/org/gnome/desktop/remote-access/'>
*.enums.xml files are for custom enumeration declaration, to be used as new data types in *.gschema.xml with same schema id.
$ cat /usr/share/glib-2.0/schemas/org.gnome.Vino.enums.xml
<!-- Generated data (by glib-mkenums) -->
<schemalist>
<enum id='org.gnome.Vino.VinoIconVisibility'>
<value nick='never' value='0'/>
<value nick='always' value='1'/>
<value nick='client' value='2'/>
</enum>
</schemalist>
<!-- Generated data ends here -->
$ gsettings range org.gnome.Vino icon-visibility
enum
'never'
'always'
'client'
$ gsettings get org.gnome.Vino icon-visibility
'client'
Compiling Schema's (Ref: Playing with dconf and gnome-tweak-tool)
As part of the installation process (it has a dpkg trigger), schema's are compiled with glib-compile-schemas tool (from glib)
sudo glib-compile-schemas /usr/share/glib-2.0/schemas
*.gschema.xml will be compiled to a binary file /usr/share/glib-2.0/schemas/gschemas.compiled
Vendor Override Files (*.gschema.override)
In addition to schema files, glib-compile-schemas reads vendor override files, which are key files that can override default values for keys in the schemas (Ref: man glib-compile-schemas). They contain the changes done by Ubuntu distribution to override upstream schema defaults.
$ ls /usr/share/glib-2.0/schemas/*.gschema.override
/usr/share/glib-2.0/schemas/10_compiz-gnome.gschema.override
/usr/share/glib-2.0/schemas/10_desktop-base.gschema.override
/usr/share/glib-2.0/schemas/10_evolution-common.gschema.override
/usr/share/glib-2.0/schemas/10_gnome-settings-daemon.gschema.override
/usr/share/glib-2.0/schemas/10_gnome-shell.gschema.override
/usr/share/glib-2.0/schemas/10_gnome-system-log.gschema.override
/usr/share/glib-2.0/schemas/10_gsettings-desktop-schemas.gschema.override
/usr/share/glib-2.0/schemas/10_libgtk-3-common.gschema.override
/usr/share/glib-2.0/schemas/10_ubuntu-settings.gschema.override
/usr/share/glib-2.0/schemas/20_ubuntu-gnome-default-settings.gschema.override
$ cat /usr/share/glib-2.0/schemas/10_gnome-settings-daemon.gschema.override
[org.gnome.desktop.wm.keybindings]
switch-input-source=['<Super>space']
switch-input-source-backward=['<Shift><Super>space']
Example of override files use, See How to customize the Ubuntu Live CD? (5. Customization 2: Backgrounds and Themes).
Lock files
Currently, dconf supports only per-key locking, no sub-path lock. User defined values will still be stored in user-db but will have no effect on applications. dconf/gsettings returns default values instead for those locked keys. Lock files are stored in db.d/locks/. Example:
$ cat /etc/dconf/db/gdm.d/locks/00-upstream-settings-locks
/org/gnome/desktop/a11y/keyboard/enable
/org/gnome/desktop/background/show-desktop-icons
/org/gnome/desktop/lockdown/disable-application-handlers
/org/gnome/desktop/lockdown/disable-command-line
/org/gnome/desktop/lockdown/disable-lock-screen
/org/gnome/desktop/lockdown/disable-log-out
/org/gnome/desktop/lockdown/disable-printing
/org/gnome/desktop/lockdown/disable-print-setup
/org/gnome/desktop/lockdown/disable-save-to-disk
/org/gnome/desktop/lockdown/disable-user-switching
...
After locks modification, to be effective run:
sudo dconf update
A good showcase: dconf Settings: defaults and locks
Changing Global Settings
The default for gsettings/dconf-editor is to edit the user-db. To change system-db, write a new override file and recompile schema's.
I couldn't get this to work:
sudo su gdm -c 'gsettings ...'
neither the other answers here Set Default/Global Gnome Preferences (Gnome 3), may be that was for an old release.
/.config/dconf目录中),并为第二个用户部署另一套设置,该怎么做呢?)?据我所知,“文本样式存储”仅支持系统范围的设置,是吗?有没有办法只导出用户设置(例如/.config/dconf/user中的设置)?我知道可以使用“dconf dump /”来导出整个用户数据库,包括系统默认设置。但是文档非常不完整。 - Anatolidconf dump /只会导出用户修改过的条目,不包括从未更改或已重置的条目(例如,它会包括那些已更改或设置的条目,即使它们的值与默认值相同)。请参考 https://askubuntu.com/q/420527/26246 。此外,并非整个数据库都会被导出,你可以设置路径。例如:dconf dump /com/。 - user.dzdconf load / < file。 - Anatolisudo su username2 -c "dconf load / < file"。 - user.dzsu username -c "dconf load /"是不够的。但幸运的是,有一种简单的方法可以完成这个任务:在dconf load前加上dbus-launch前缀,即:sudo su username2 -c "dbus-launch dconf load / < file"。之后唯一的问题就是杀死两个新创建的进程:dbus-daemon和dconf-service,但这是可以解决的(它们的父进程是调用sudo命令的用户的upstart进程)。 - Anatoligsettings list-recursively命令返回重复和三重设置?https://askubuntu.com/questions/1090244/dconf-database-how-to-remove-duplicate-triplicates - WinEunuuchs2Unix