You Got A Question? Ask    GNOME Community!

Extending Gnome Tweak Tool 3.10!

Tweak Tool in one of the most favorites utilities in Gnome, and is kinda necessary as it provides essential things that default Gnome Settings doesn’t. Tweak Tool basically is a nice interface to GSettings that displays the most common options/settings.

So what if we are missing something? Well, we can add it!

The point isn’t to hack Tweak Tool for our own use, but you might want to add stuffs and ask Tweak Devs if they want to add them on the next official releases, so more people can take advantage of them.

For example

For example I added a new Session Menu, that enables us to save our session (I think there isn’t such option in Gnome 3.10?).


A new option for saving session

One bad thing in Tweak Tool is that doesn’t accept plugins. I am not sure why they did that, because writing a plugin engine in the existence code it would be trivial.


For this guide you need GNOME 3.10 and Gnome Tweak Tool 3.10 and is also nice to have dconf-editor so you can easily see the Schemas Keys.


Auto Save Session Key in Dconf-Editor

Tweak Tool is written in Python but you don’t need absolutely any knowledge of Python, since the code is really simple. You just need to see how other components work and copy code.

I used my JHBuild installation to hack into Tweak Tool, but it is safe to use the default packages. If things go wrong, you can just re-install it :)

You will find Tweak Tools files at:

DATA_DIR = "/opt/gnome/share"
PKG_DATA_DIR = "/opt/gnome/share/gnome-tweak-tool"
GSETTINGS_SCHEMA_DIR = "/opt/gnome/share/glib-2.0/schemas"
TWEAK_DIR = "/opt/gnome/lib/python2.7/site-packages/gtweak/tweaks"
LOCALE_DIR = "/opt/gnome/share/locale"


Adding the Session Option

1. Open file and add:




2. Create an empty file inside Tweaks and name it

3. Edit

import gtweak
from gtweak.gshellwrapper import GnomeShellFactory
from gtweak.tweakmodel import TWEAK_GROUP_SESSION
from gtweak.widgets import ListBoxTweakGroup, GSettingsSwitchTweak

_shell = GnomeShellFactory().get_shell()
_shell_loaded = _shell is not None


        GSettingsSwitchTweak(_("Auto Save Session"), "org.gnome.SessionManager", "auto-save-session"),

4. Done! You can launch now Gnome Tweak Tool and you will see the new option!

You know that you will lose your changes (at leastin on Tweak update, right? ;)

On the above example I used the less possible code. Some things can be harder. For instance initially I tried to edit “org.gnome.nautilus.preferences” schema, but it was missing from “/opt/gnome/share/glib-2.0/schemas” and you had to hack things in this case.

However the code is clean and easy to understand (even if I don’t know Python) and Tweak Tool provides all the set of Widgets you will need to start adding options and interfaces.

Fork it on Github!

If you feel that Tweak Tool is missing an option, file a report to Bugzilla and say that I want to add this “x” feature. If Tweak devs approve it, fork Tweak Tool on Github and send the patches again back in Bugzilla.

I also think it would be okay to directly email to John Stowers (GTT maintainer) and ask him for guidance.

By the way, I just opened GTT code to see how GTT was looping through GSettings Keys Values.

  We can't watch comments unless G+ provides an API or if you send a notification, e.g +World Of Gnome
     Sometimes is better to place your questions on GNOME Community
  • Michael Heyns

    +1 Internets to you, kind sir!