Jump to content

GNOME

From MukeWiki

dconf

dconf is a simple key/value storage system (database) that is heavily optimised for reading. This makes it an ideal system for storing user preferences (which are read 1000s of times for each time the user changes one). All user preferences are stored in a single large binary file. 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. Most applications will not want to interface directly with dconf, but rather with GSettings.

dconf je nizkourovnovy backend/system na ukladanie pouzivatelskych nastaveni typu key/value, silne optimalizovany na rychle citanie. GSettings je vyssieurovnove API, ktore aplikaciam poskytuje standardizovany sposob prace s nastaveniami (pracuje so schemami, ktore definuju kluce, typy hodnot a ich default hodnoty). V GNOME je dconf standardnym backend-om pre GSettings. GSettings je navrhnute ako API nezavisle od backend-u, t.j. moze pouzivat aj ine backends. Napr. pri testovani sa mozu nastavenia ukladat do pamate (memory backend) a nemusia byt ani trvalo ulozene. Prave to je vyhoda oddelenia API od backend-u, aplikacia pracuje s API (GSettings), ale sposob ulozenia riesi backend (napr. memory alebo dconf).

Aplikacia => GSettings (rozhranie/API) => dconf (backend) => dconf databaza

Pre uzivatela sa odporuca pouzivat gsettings(1)rpm (GSettings configuration tool) a dconf(1)rpm (simple tool for manipulating a dconf database) je vhodny skor na nizkourovnovu pracu s databazou, diagnostiku alebo backup.

Profile (text file) obsahuje zoznam konfiguracnych databases (binary files), ktore dconf vyhladava. User (personal) database ma vzdy najvyssiu prioritu, potom nasleduju system databases v poradi predpisanom profilom. Program dconf(1) pri spusteni preveruje hodnotu environment variable DCONF_PROFILE, ktora specifikuje aky profile (text file) sa ma pouzit, inak sa predpoklada profile s nazvom "user". DCONF_PROFILE moze urcovat relativnu cestu k profile suboru v /etc/dconf/profile/ dir alebo absolutnu cestu. V pripade ak profile file neexistuje v /etc/dconf/profile/ dir, potom sa este prehladava aj $XDG_DATA_DIRS/dconf/profile/ dir(s). See also dconf(7) and dconf-engine-profile.c for more info.

DCONF_PROFILE=test   # find profile file (in this order):
/etc/dconf/profile/test or /usr/local/share/dconf/profile/test or /usr/share/dconf/profile/test

Profile file (text file) obsahuje jeden alebo viac riadkov, ktore musia zacinat s database source.

user-db:user    # $XDG_CONFIG_HOME/dconf/user # user writable database binary file user in $HOME/.config/dconf/ dir
system-db:local # /etc/dconf/db/local         # system read-only database binary file local in /etc/dconf/db/ dir

file-db:/path/to/db/file                      # read-only database binary file /path/to/db/file
service-db:keyfile/user                       # special/specific writable database

Kazdy jeden riadok profile predstavuje prave jednu database (binary file).

# /etc/dconf/profile/user in Fedora (source from dconf>rawhide>dconf.specrpms)
user-db:user
system-db:local
system-db:site
system-db:distro

# /etc/dconf/profile/ibus in Fedora (source from ibus profile)
user-db:user
system-db:ibus
$ dconf dump /   # same as $ DCONF_PROFILE=user dconf dump /
# profile file: /etc/dconf/profile/user
# database files (in this priority): $HOME/.config/dconf/user, /etc/dconf/db/local, /etc/dconf/db/site, /etc/dconf/db/distro
# NOTE V pripade ak by "user" profile file neexistoval ani v '/etc/dconf/profile/' ani v '$XDG_DATA_DIRS/dconf/profile/' dir, potom sa bude postupovat akoby subor profile existoval a obsahoval prave jeden riadok: 'user-db:user'.

$ DCONF_PROFILE=ibus dconf dump /
# profile file: /etc/dconf/profile/ibus
# database files (in this priority): $HOME/.config/dconf/user, /etc/dconf/db/ibus

# TIP Moznost ako si pozriet obsah len jednej konkretnej database (jeden binary file).
$ printf "file-db:/etc/dconf/db/distro\n" > /tmp/tmp-profile
$ # printf "system-db:distro\n" > /tmp/tmp-profile2   # equivalent, dconf automatically finds 'distro' file
$ DCONF_PROFILE=/tmp/tmp-profile dconf dump /
# profile file: /tmp/tmp-profile
# database file: /etc/dconf/db/distro

Keyfile (text file) ulahcuje konfiguraciu database pomocou jednoducheho textoveho suboru. Pre lubovolnu systemovu database je mozne umiestnit keyfile do konfiguracneho /etc/dconf/db/<database>.d/ adresara. Po zmene keyfile (text file) je potrebne database aktualizovat (update) pomocou dconf(1).

Locks (text file) obsahuje lock (zamok) pre nejaky key zo systemovej database. Pouziva sa na vynutenie povinnych nastaveni. Textovy subor sa umiestnuje do /etc/dconf/db/<database>.d/locks/ adresara a analogicky je potrebne po zmene aktualizovat database. Priorita v pripade viacerych systemovych databases je opacna, ziadna database uvedena vyssie v profile nebude moct zmenit lock key.

See also GNOME Help: [1], [2] or [3].

GSettings

GSettings schemas definuju rozne nastavenia pre GNOME desktop a aplikacie. Su ulozne v $XDG_DATA_DIRS/glib-2.0/schemas/ dir ako XML subory. Compiler glib-compile-schemas(1)rpm skompiluje vsetky GSettings XML schemas files do jedneho velkeho binary file /usr/share/glib-2.0/schemas/gschemas.compiled, ku ktoremu pristupuje GSettings API, ktore poskytuje jednoduche CLI rozhranie prostrednictvom gsettings(1)rpm nastroja.

$ gsettings --schemadir /path/to/schemas/ list-recursively   # try in 'gnome-shell/extensions/'

$ gsettings list-recursively   # user specific settings and identical as
$ gsettings --schemadir /usr/share/glib-2.0/schemas list-recursively

Vytvorenie subora s filename extension *.gschema.override poskytuje moznost nastavenia vlastnych default hodnot. Tato moznost upravy default hodnot sa ale skor odporuca pre distribucie/vendor.

gsettings(1) potrebuje D-Bus session bus connection na zapis zmien do dconf database. D-Bus (Desktop Bus, sucast freedesktop.org projektu) je mechanizmus inter-process communication (IPC) v Linuxe. Umoznuje procesom posielat si navzajom spravy a volat funkcie bez toho, aby medzi sebou komunikovali priamo. Pri pouziti dconf backend je D-Bus komunikacnym kanalom medzi GSettings a dconf service.

gsettings => GSettings <=> D-Bus <=> dconf service => dconf database
$ gsettings list-recursively org.gnome.desktop.screensaver | grep -iE 'logout|reboot|restart'
$ gsettings list-recursively | grep -iE 'logout|reboot|restart'

$ gsettings list-recursively > all.user.settings
$ dconf dump /               > all.user.explicit.settings

$ gsettings reset org.gnome.calculator button-mode
$ gsettings reset-recursively org.gnome.calculator
$ dconf reset -f             /org/gnome/calculator/   # equivalent via 'dconf'

$ gsettings reset-recursively org.gnome
No such schema “org.gnome”
$ # dconf reset -f /org/gnome/         # !!! carefully !!! reset all in /org/gnome/ dir
$ # dconf reset -f /                   # !!! carefully !!! equivalent rm $HOME/.config/dconf/user

dconf vs gsettings

$ dconf write /non/exist/key 12345            |   $ gsettings set non.exist key 12345
                                              |   No such schema “non.exist”
$ dconf read /non/exist/key                   |   $ gsettings get non.exist key
12345                                         |   No such schema “non.exist”

Toto je jedna z hlavnych pricin preco sa odporuca pouzivat gsettings(1), ktory "preveruje co robim" (validuje schema, key a value podla GSettings schema) a nie nizko urovnovy dconf(1), ktory priamo manipuluje s dconf database.

$ gsettings reset org.gnome.calculator button-mode
# => removes key '/org/gnome/calculator/button-mode' from user dconf database, i.e. resets to default
$ gsettings get org.gnome.calculator button-mode
'basic'   # get default value from GSettings schemas
$ dconf read /org/gnome/calculator/button-mode
# => no output; no dconf database entry with this key, key '/org/gnome/calculator/button-mode' was removed
$ gsettings set org.gnome.calculator button-mode 'programming'
# => set (store) key '/org/gnome/calculator/button-mode' to value 'programming' in user dconf database
$ gsettings get org.gnome.calculator button-mode
'programming'
 $ dconf read /org/gnome/calculator/button-mode
'programming'
$ gsettings set org.gnome.calculator button-mode 'blabla'
The provided value is outside of the valid range
$ dconf write /org/gnome/calculator/button-mode "'blabla'"
# => directly write 'blabla' to user dconf database, bypassing GSettings schemas validation
$ dconf read /org/gnome/calculator/button-mode
'blabla'
$ gsettings get org.gnome.calculator button-mode
'basic'   # default 'basic' because stored 'blabla' is not a valid enum value in the GSettings schemas

NOTE Moze sa javit, ze user dconf database obsahuje len non default values. V skutocnosti 'gsettings set' zapise do dconf database kazdu valid hodnotu, teda aj default hodnotu.
$ gsettings set   org.gnome.calculator button-mode 'basic' # ulozi sa aj default hodnota v donf database
$ gsettings reset org.gnome.calculator button-mode         # odstrani sa key z dconf database

Configuration

Na upravu default hodnot pre GNOME desktop a aplikacie sa moze pouzit:

  • dconf overrides pre systemovych administratoroch
  • GSetting overrides urcene skor pre distribucie (vendorov)
GNOME configuration tools
gnome-control-center(1)rpm basic GUI Configure GNOME settings
gnome-tweaksrpm advanced GUI Graphical interface for advanced GNOME settings
gsettings(1)rpm expert CLI GSettings configuration tool
dconf(1)rpm expert CLI Simple tool for manipulating a dconf database
dconf-editor(1)rpm expert GUI Graphical editor for gsettings and dconf
GConf (gconftool-2 a gconf-editor) z GNOME 2 bol v GNOME 3 nahradeny GSettings (gsettings a dconf-editor)

Power

Pravdepodobne najmenej user friendly (intuitivne) nastavenia. Napr. pouziva sa pojem screensaver, no v skutocnosti najnovsi GNOME (a Wayland) nema ziaden screensaver. Pod screensaver mozno rozumiet vypnutie monitora (blank).

/usr/share/glib-2.0/schemas/org.gnome.desktop.session.gschema.xml
org.gnome.desktop.session idle-delay 300 The number of seconds of inactivity before the session is considered idle.
Po idle-delay sekundach (0 sekund = nikdy) necinnosti sa vypne monitor (blank), co mozno chapat ako spustenie screensaver.
V GNOME Settings (gnome-control-center) v sekcii Power\Power Saving ako polozky: Automatic Screen Blank a Delay.
/usr/share/glib-2.0/schemas/org.gnome.desktop.screensaver.gschema.xml
org.gnome.desktop.screensaver lock-delay 0 The number of seconds after screensaver activation before locking the screen.
Po lock-delay sekundach (0 sekund = ihned) a potom ako idle-delay (vid vyssie) sa uzamkne obrazovka, t.j. v skutocnosti po sume obidvoch idle-delay + lock-delay.
org.gnome.desktop.screensaver lock-enabled true Set this to TRUE to lock the screen when the screensaver goes active.
Len v pripade lock-enabled je mozne uzamknutie obrazovky (kedze unsigned lock-delay = 0 znamena ihned a nie nikdy).

Ak nastavime idle-delay na 0 sekund (na nikdy) tak potom nikdy nenastane ani uzamknutie obrazovky, kedze uzamknutie nastava az po uplynuti idle-delay. V takom pripade jedina moznost uzamknutia obrazovky je kliknutim v pravom hornom rohu obrazovky na ikonu Lock Screen (resp. cez CLI $ loginctl(1)rpm lock-session).

Zaroven plati, ze ak nastane uzamknutie obrazovky (po uplynuti idle-delay + lock-delay) tak to uzamknutie nastane pri vypnutom monitore (blank), kedze monitor sa vypol v dosledku idle-delay. Po prebudeni, zapnuti monitora (pohybom mysi alebo stlacenim klavesu) vidime uzamknutu obrazovku. Tuto vlasnost umoznuje obist napr. Unblank lock screen GNOME extension.

V pripade necinnosti pri uzamknutej obrazovky sa monitor znova vypne po uplynuti idle-delay.


/usr/share/glib-2.0/schemas/org.gnome.settings-daemon.plugins.power.gschema.xml
org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout 900 The amount of time in seconds the computer on AC power needs to be inactive before it goes to sleep. A value of 0 means never.
Po sleep-inactive-ac-timeout sekundach (0 sekund = nikdy) necinnosti prejde pocitac do rezimu sleep (vid nizsie). Tento timeout je plne nezavisly uz od skor spomenuteho idle-delay.
V GNOME Settings (gnome-control-center) v sekcii Power\Power Saving ako polozky: Automatic Suspend a Delay.
org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'suspend' The type of sleeping that should be performed when the computer is inactive.
Enum sleep-inactive-ac-type: 'blank', 'suspend', 'shutdown', 'hibernate', 'interactive', 'nothing' or 'logout'.

V tomto pripade je viac menej vsetko jasne a intuitivne. Okrem nastaveni pre AC power existuju ekvivalentne nastavenia aj pre battery power. Ak nechceme aby sa PC vypinal (AC power), mame dve moznosti:

sleep-inactive-ac-timeout nastavit hodnotu 0 alebo
sleep-inactive-ac-type nastavit ako 'nothing', resp. asi vhodnejsie 'blank' (vypnut monitor)

NOTE V pripade ak instalujeme Fedora ako Fedora Server release, tak sa aplikuje fedora-release>rawhide>org.gnome.settings-daemon.plugins.power.gschema.overriderpms schema.

GDM

Fedora pre GDM (GNOME Display Manager) pridava vlastny dconf profile patch, see gdm/tree/rawhiderpms.

# /usr/share/dconf/profile/gdm in Fedora (source from gdm>rawhide>0001-data-add-system-dconf-databases-to-gdm-profile.patchrpms)
user-db:user
system-db:gdm
system-db:local
system-db:site
system-db:distro
file-db:/usr/share/gdm/greeter-dconf-defaults

Pre "gdm" profile (text file) sa v tomto pripade pouziva $XDG_DATA_DIRS/dconf/profile/ dir a preto uz nie je potrebne vytvarat subor /etc/dconf/profile/gdm ako sa uvadza v roznych (no Fedora) dokumentaciach. Systemova gdm database (binary file) ako aj gdm keyfile (and locks) sa nachadzaju v /etc/dconf/db/ dir spolu so vsetkymi ostatnymi systemovymi databases.

Hlavny dovod preco sa tu vlastne spomina GDM je default nastavenie pre Fedora Workstation. GDM login screen po 900 sekundach necinnosti prechadza do sleep stavu 'suspend' (vid sekcia Power) a teda (okrem ineho) nie je mozne napr. SSH prihlasenie na taketo PC, see also [4].

# /etc/dconf/db/gdm.d/01-muke-customize-gdm     # gdm keyfile

# Monitor blanks (turns off) after 10 minutes, while the computer keeps running.
[org/gnome/settings-daemon/plugins/power]
sleep-inactive-ac-timeout=600
sleep-inactive-ac-type='blank'
power-button-action='nothing'
$ sudo dconf update
# => updated all databases (binary files), i.a. /etc/dconf/db/gdm

GNOME Shell

GNOME Shell je zakladna cast user interface v GNOME 3 (spusta aplikacie, prepina okna a pod.), pouziva Mutter (compositing window manager) a je stale aktivne vyvijane. Moze sa flexibilne upravovat pomocou roznych extensions, ktore jednoducho nacitavaju JavaScript a CSS. Je to nahrada za pred tym pouzivane applets a widgets. Subory s GNOME Shell extensions sa nachadzaju v /usr/share/gnome-shell/extensions/<extName>/ resp. $HOME/.local/share/gnome‑shell/extensions/<extName>/ dir.

GNOME Extensions tools
gnome-extensions(1)rpm CLI Command line tool for managing GNOME extensions
gnome-extensions-apprpm GUI Manage GNOME Shell extensions
https://extensions.gnome.org/local/ Web Find and install GNOME Shell extensions using website
NOTE gnome-shell-extension-prefs and gnome-shell-extension-tool are deprecated, use gnome-extensions instead.
$ dnf list gnome-shell-extension\*      # available extensions in system (Fedora)
$ dnf remove gnome-shell-extension\*    # installing extensions from a web browser instead of system packages
$ dnf install gnome-browser-connector   # GNOME Shell browser connector is required

$ gnome-extensions list                              # installed extensions
$ gsettings get org.gnome.shell enabled-extensions   # enabled extensions

GNOME Shell Extensions

Install GNOME Shell Extensions from source https://gitlab.gnome.org/GNOME/gnome-shell-extensions
git clone https://gitlab.gnome.org/GNOME/gnome-shell-extensions.git
cd gnome-shell-extensions/
git checkout gnome-50   # set actual version or main branch
head meson.build        # check version version: '50.3'
./export-zips.sh

gnome-extensions install zip-files/apps-menu@gnome-shell-extensions.gcampax.github.com.shell-extension.zip
gnome-extensions install zip-files/window-list@gnome-shell-extensions.gcampax.github.com.shell-extension.zip
gnome-extensions enable apps-menu@gnome-shell-extensions.gcampax.github.com
gnome-extensions enable window-list@gnome-shell-extensions.gcampax.github.com

Other Shell Extensions

SDIR="$HOME/.local/share/gnome-shell/extensions/simple-weather@romanlefler.com/schemas"
gsettings --schemadir "$SDIR" reset-recursively org.gnome.shell.extensions.simple-weather

gsettings --schemadir "$SDIR" set org.gnome.shell.extensions.simple-weather panel-box 'center'
gsettings --schemadir "$SDIR" set org.gnome.shell.extensions.simple-weather show-refresh-button true

EasyScreenCast, Vitals, Frippery Applications Menu, Frippery Bottom Panel

Example how to configure GNOME Shell Extensions
SDIR="$HOME/.local/share/gnome-shell/extensions/system-monitor-next@paradoxxx.zero.gmail.com/schemas/"
gsettings --schemadir "$SDIR" reset-recursively org.gnome.shell.extensions.system-monitor-next-applet

gsettings --schemadir "$SDIR" set org.gnome.shell.extensions.system-monitor-next-applet background '#ffffff16'
gsettings --schemadir "$SDIR" set org.gnome.shell.extensions.system-monitor-next-applet icon-display false
gsettings --schemadir "$SDIR" set org.gnome.shell.extensions.system-monitor-next-applet show-tooltip true
gsettings --schemadir "$SDIR" set org.gnome.shell.extensions.system-monitor-next-applet cpu-style 'both'
gsettings --schemadir "$SDIR" set org.gnome.shell.extensions.system-monitor-next-applet cpu-graph-width 80

Screenshots

Z relativne trivialnej zalezitosti sa s pouzitim najnovsieho GNOME v kombinacii s Wayland-om stava problem.

Povodna samostatna aplikacia GNOME Screenshot sa s prichodom GNOME 42 (released 2022-03) meni na built-in utility in GNOME Shell. Samostatna aplikacia gnome-screenshot(1)rpm je sice este distribuovane, ale uz nefunkcna (and archived). Built-in GNOME Screenshots and screencasts sa spusta jednoducho stlacenim PrtSc klavesy. Ponuka tri moznosti: Selection, Screen a Window.

  • problem-1 nastava pri Window screenshot, kedy sa zachytava aj transparency shadow effect okolo samotneho window. Nie je to chyba, ale vlastnost Wayland, resp. Mutter, ktory pridava dekoracie, jemny tien, resp. prehladny okraj. Niekedy je to dokonca ziaduci efekt.
$ magick input.png -fuzz 50%                 -trim +repage output.png
#   vseobecne odporucane riesenie nie je stale funkcne
$ magick input.png -channel A -threshold 50% -trim +repage output.png   # -alpha off # -strip
#   funkcne riesenie pre odstranenie shadow effect (default Adwaita theme)
  • problem-2 Window screenshot vzdy vybera iba jedno top-level okno a napr. dialogove alebo about okno ponuka len ako samostatne a nie ako ich composite. Vtedy je potrebne vybrat Selection screenshot a tu nastava problem ako presne vyrezat (crop) window zo selection. Kedze pouzivam jednofarebny desktop background, tak pouzijeme ImageMagick na auto-crop.
$ magick input.png -fuzz 33% -trim +repage output.png
#   -fuzz udava toleranciu podobnych farieb (jednofarebne pozadie), see [5] and [6]

NOTE Pre potrebnu, vhodnu zmenu velkosti okna pouzivame Screenshot Window Sizer GNOME Shell Extension.


Otestovany (Fedora, GNOME Wayland) Screen capture software:
NEFUNKCNE:

FUNKCNE (vsetky tri aplikacie maju vstavany editor, resp. annotation tool):

  • flameshot Qt-based super, ale neviem vybrat potrebne window, len screen resp. selection cez vstavany editor (annotation tool).
  • shutter Gtk3 in Perl, OK, pod Wayland limitovane moznosti, len screen resp. selection cez vstavany editor (annotation tool).
  • ksnip Qt-based ale pod Wayland len screen resp. selection cez vstavany editor (annotation tool).