Editing dconf/gsettings from python
You really shouldn't use
os.system() for system calls anymore, it has been deprecated and totally outdated for a long time.
There are different options to edit the
Say I have a
/com/gexperts/Tilix/keybindings/app-shortcuts, I can use:
key = "/com/gexperts/Tilix/keybindings/app-shortcuts"
"dconf", "write", key, "'enabled'"
Mind the quoting!
In most cases however, you will also be able to use (better)
Gio.Settings if the value also can be set from
from gi.repository import Gio
key = "com.gexperts.Tilix.Keybindings"
settings = Gio.Settings.new(key)
See also https://lazka.github.io/pgi-docs/#Gio-2.0/classes/Settings.html#Gio.Settings and https://people.gnome.org/~gcampagna/docs/Gio-2.0/Gio.Settings.html
Preferences on modern Ubuntu versions are mostly stored in the
dconf database in binary format. These settings can be edited directly by
dconf (cli), or
dconf-editor (gui). Dconf is low level, and directly editing settings via
dconf extremely fast and light-weight.
In general it is however considered better practice to edit settings in the database via
gsettings if possible, which is the cli frontend to
dconf. The reason is that
gsettings has a consistency check, safer to use.
You might find this an interesting read on
And this one on
- I used another path / key example since I don't run Unity.