brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: gsettings range shows which values a setting accepts

Linux
~/tips/tip-gnome-gsettings-range-describe

gsettings range SCHEMA KEY

Lists the valid values and the description of a gsettings key before you set it.

Typing a value into gsettings set and hoping is how you end up with a rejected string or a quoting mess. Two read-only commands tell you what a key wants first.

gsettings describe SCHEMA KEY
gsettings range SCHEMA KEY

According to the man page, describe queries the description of valid values for the key, and range queries the range of valid values. Here is what they printed for a key of the GTK file chooser on Ubuntu 24.04:

$ gsettings describe org.gtk.Settings.FileChooser show-hidden
Controls whether the file chooser shows hidden files or not.
$ gsettings range org.gtk.Settings.FileChooser show-hidden
type b
$ gsettings range org.gtk.Settings.FileChooser sort-column
enum
'name'
'size'
'type'
'modified'

A boolean key reports type b. A key with a fixed set of choices reports enum followed by the allowed strings, and the quotes are part of the value. So gsettings set org.gtk.Settings.FileChooser sort-column 'size' is a valid call, and it is why the string goes in quotes.

I find describe the more useful of the two when a key name is vague, because the schema author wrote that sentence for exactly this moment.

Caveats: not every key has a description, and the output of range varies with the type. The man page also lists gsettings writable SCHEMA KEY, which tells you whether the key can be written at all. Setting a value still needs a D-Bus session bus, as the man page notes.

Further reading: gsettings(1) man page

Going deeper: Guide: advanced tmux, a config that grows with you, formats, layouts and more

More Linux tips notify-send -r "$id" "Backup" "Done" pgrep -af 'sleep 301' smbstatus -L msmtp --serverinfo --tls --tls-certcheck=off --host=smtp.example.com --port=587 smbclient //server/share -U user -Tc backup.tar "*" All Linux tips (283) All topics

Link