Luke Carrier

Unbreaking gconf/dbus

Published 2 years ago

If you've really ballsed up your Linux desktop (e.g. by setting /org/gnome/desktop/interface/scaling-factor to a six figure number, for science of course) and can't get a terminal open to fix it, all is not lost!

The way settings are stored in most Gnome-based desktop Linux distributions is relatively simple: you have some form of key-value store (usually dconf, sometimes gconf on older distributions) with a friendly layer of command line tools and APIs on top (such as gsettings).

When your system boots, don't log in to the login window. Instead, you'll want to switch to a different virtual terminal. Most distributions start 7 and leave 6 of them free for you use. Ubuntu, for instance, runs GDM/Unity on TTY7, leaving 1 through 6 free. On Fedora, TTY1 is consumed, leaving 2 through 7 free. Hit Ctrl+Alt+F<TTY number> to switch. When you've switched, log in with your usual username and password.

You'll now need to start dbus so that we can make changes to configuration values in dconf. To do this, execute the following to start dbus and replace the running instance of your shell with a new one with the dbus environment variables set:

$ exec dbus-launch $SHELL

With dbus running, we can now make changes to dconf. Keys in dconf are stored in a hierarchical registry. To set the value of the /org/gnome/desktop/interface/scaling-factor key to 2, we enter the following:

$ dconf write /org/gnome/desktop/interface/scaling-factor 2

This is functionally equivalent to writing:

$ gsettings set /org/gnome/desktop/interface scaling-factor 2

Once we're done tinkering with the settings, we can either exit and switch back to the appropriate TTY or reboot as appropriate.