Skip to content

Manage GNOME settings from command line with gsettings (with examples)

The Puzzle

I was adding locations to my world clock in GNOME desktop yesterday, since I want to track the local time of clients and colleagues around the world. I added the cities in the settings panel and went to the notification panel to look for them, but nothing was there.

I thought maybe there was a switch that needed to be flipped, so I tried to open gnome-tweak-tool. Suddenly, my desktop crashed, and kicked me back to the GDM login screen. I tried to log back in, and it just looped back to the login screen. No good. Tried rebooting and that didn’t help either.

Sometimes running Linux is like a puzzle, and the reward for solving it is getting to use your computer again.

Rebooted and used Ctrl-Alt-F2 to switch over to a text console and was able to log in that way. Once I logged in, took a look at the systemd journal:

journalctl -xe

where -x“augments log lines with explanation texts from the message catalog” and -e just moves us to the end of the log (man journalctl).

The Fix

After some searching in the log, the following error was revealed:

May 2 12:04:20 gnome-shell[4353]: JS ERROR: TypeError: b.location.get_timezone(...) is null

Now I was sure it was due to one of the world clock locations. Did a bit more research, and as usual the Arch Linux Forums delivered the following command:

gsettings reset org.gnome.clocks world-clocks

Ran that command, Ctrl-Alt-F1 to get back to GDM login, and we’re back in business!

The Solution

It turns out that gsettingsis a pretty neat little tool that comes with gnome to manage its configuration from the command line. You can run

gsettings help

to get a top level overview of the command. If we run

gsettings list-schemas

We get a listing of all schemas. We can see from that list that the org.gnome.clocks from our command above was one schema out of many. Each schema has a set of keys which define configuration for gnome. If we run

gsettings list-keys org.gnome.clocks

we get a list of keys with values we can change in that schema:

timer
geolocation
world-clocks
alarms

This is where the world-clocks key resided.

Using this knowledge plus the reset command allows you to reset any GNOME configuration that locks you out of your desktop in the future. You can also use this tool to automatically configure desktops, backup desktop configuration, etc. Let me know what other uses you find!

Published inDevelopment

Be First to Comment

Leave a Reply