Configuring Gnome with gsettings and dconf

When I first started using Fedora and Gnome, I usually went through the Settings app taking each section and fine tuning my install. It’s a good way to setup your experience while also discovering what’s new in the latest version of Gnome. But Gnome offers another way of managing settings using the command line and today we will see just how easy it works.

Managing settings from the command line is especially useful if you already went through the steps of configuring your system many times and you just want your setup quickly without fiddling with the Settings app. The main use case is a new Linux install: you just want to be back to your usual desktop as soon as possible and you don’t care much about what new settings are there. Or at least you want a good baseline configuration to start with. The tools we will visit today are gsettings and dconf. Let’s see how they work.

How settings look in Gnome

Gnome has a sort of registry that holds all settings and each setting has a path, a key and a value. An example of a path is org/gtk/settings/file-chooser which holds settings for the file picker you get when browsing for files in a File Open dialog of a GTK application. One setting for the file-chooser path is for example sort-directories-first. That would be the key. The value for that key could be true or false.

Some keys allow you to write any string for them, others are true or false, others are numbers and others are predefined values like ascending and descending for sort-order. You can configure pretty much all of your Gnome experience using these settings and once you understand how they look, it becomes easy to find your way around.

Configuring Gnome one setting at a time

The first tool we will talk about is gsettings. This tool allows you to pick one path and one setting and get or set its value. The basic syntax is this:

#gsettings get org.gtk.Settings.FileChooser sort-directories-first

The result will be true or false, depending on how it was configured. If you want to set the value, you simply use set instead of get and add the value at the end like this:

#gsettings set org.gtk.Settings.FileChooser sort-directories-first true

The gsettings command also lets you see all the paths available. This is useful when you try to find your way around and don’t exactly know what is there in the registry:

#gsettings list-schemas

The result will be a full listing of everything that’s out there:

If we want to explore the settings for the File Chooser, we can use the list-keys parameter:

#gsettings list-keys org.gtk.Settings.FileChooser

The output will show us all the settings available:

And finally if we don’t know what values a certain setting allows, we can use the range parameter like this:

#gsettings range org.gtk.Settings.FileChooser sort-order

This will give you the setting type and the allowed values. It’s all very well put together and it allows you to pin point a configuration and set it as you prefer. The only limitation for the gsettings command is that it changes one setting at a time. This is not too bad, we can have scripts with multiple gsettings commands to set everything up, but there’s a better way.

Changing multiple settings with a single command

This is the land of the dconf tool. This tool does two things and they are both great for fully setting up our Gnome environment exactly how we like it. It has more options but the ones we are interested in right now are dump and load. It’s easy to guess what they do:

#dconf dump /

The dump parameter requires a root path which can be the registry root like we did above. This will dump every setting in Gnome:

Everything is included. Once we have this output, we can save it in a file and throw it on our backup folder: it basically describes the Gnome look and feel on our current desktop. Once we have that, we can use the load parameter to reset everything in Gnome to the given configuration:

#cat settings.txt | dconf load /

We can see that gsettings schemas are a bit different from dconf: one uses dots and capitalized names and the other uses slashes and dashed names but in the end it’s the same thing. We can also see that dconf expects a root parameter for both dump and load. This is because it also allows you to work with just a subset of the registry if we want to. If we only want to show and change settings for org/gtk/settings/file-chooser, we can use that as our root:

#dconf dump /org/gtk/settings/file-chooser/

Note the leading and trailing slashes: it’s a thing dconf requires for a path. Also, note the resulting location of the settings: [/], the root. It’s not the root of the registry, it’s the root of the path you specified. So if we dump these settings in a file, when we load them back make sure to specify the path again as we are writing there, not in the registry root:

#cat settings.txt | dconf load /org/gtk/settings/file-chooser/

That’s how you setup Gnome from the terminal. This is very useful as there are many hidden settings out there that are not available in the Settings app, like configuring fonts, application top bar buttons and many others. Basically this is how the Gnome Tweaks app works, this is where it makes its changes. You don’t need that app, you just need to save your configuration and load it back with dconf.

I hope this article is useful. It was a breath of fresh air when I discovered these tools and they allow me to fully setup my Gnome experience very fast after a new Linux install. Back up your Gnome experience and see you next time!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Radu Zaharia

Radu Zaharia

Still planning that trip to the Moon.