February 09, 2013 »know-how
I like the GNOME Shell and I’ve liked it since it was in the “testing”-repo of ArchLinux. It’s a fast and aesthetic desktop environment. But it’s far from offering everything you’d like to have. Luckily, it has extension support.
The following advices, instructions or facts apply to GNOME Shell 3.6.2, which is the authors current version.
Should you find that anything in this article does not work with a newer version of GNOME Shell, please report your findings in the comments below.
Note that this is not a real step-by-step guide on how to create your first extension. There are many of those out there and I would just repeat them. Instead, this is more like an advice-collection on different aspects of creating extensions. So, be sure to check the links.
Getting into the development of GNOME Shell Extensions is a little hard. The documentation is mostly not available or outdated.
Here are some sources which helped me to get started (and through development):
- Basic stuff on extensions
- Basic stuff on development
- Step-by-step tutorial
- Some in-official guidelines to get your extension on extensions.gnome.org
Be sure to defiantly check out the bold links in the list.
Getting stuff done
Above all, if you’re serious about creating your extension: Learn to read the source, Luke.
When trying to get actual work done on your extension, try consulting the docs (if existing) or search the extension repos for extensions which do similar things to what you want to do, and look at their sources. Most of them are hosted on GitHub or Bitbucket, but you can also install them and find the sources under
When searching for a specific function, or more documentation on a particular function, you can also consult manuals for bindings in different languages (thought the parameters and return-values might not match).
Making user interfaces
To get a native look-and-feel with the Shell, extensions can use St (= Shell Toolkit) to create UIs for everything that integrates with the Shell itself, and Gtk for the extension-preferences.
Since documentation on St is not available, you’ll need to do a lot of source-reading. See the GNOME Shell Sources. To understand what all files/classes do, and which part of the Shell you can manipulate how, read this excellent explanation of the St components.
LookingGlass is not particularly helpful. It only shows one line of an exception (the description) and only if they occur at startup time (when your extension is first started).
Instead, for full StackTraces and runtime-exceptions, consult the session-logfile. It might be very long and bloated, so I use this handy script to read it:
# Grabs the last session-errors from the current X11 session. # This includes full Stack-Trace of gnome-shell-extension errors. # See https://live.gnome.org/GnomeShell/Extensions/StepByStepTutorial#lookingGlass tail -n100 ~/.cache/gdm/session.log | less
Should your extension crash the whole Shell, the
session.log-file will not contain information on it, because when the shell restarts, a new log-file is created. Go get information on what crashed the shell, check the
For debugging the prefs-part of your extension, you can launch the preferences by using the
gnome-shell-extension-prefs-tool from a terminal, to see any exception-output on the console (you can also call the tool like
gnome-shell-extension-prefs [uuid], to directly show your extensions preferences).
Since there is currently no real way of debugging with breakpoints (there is, but it’s tricky), you can log to the console, using the
print()-function. You will see the output as mentioned above (either in the session-logfile or on the terminal when starting
Practically any high-level, garbage-collected language is much better than plain C, in terms of productivity, once you get used to the idiosyncrasies of the bindings to the Gnome libraries.
So, there is hope that the API documentation will improve very soon.
- Above all: Read the sources!
- Check out other extension’s sources and learn from them.
- Don’t get frustrated by the documentation. Read sources instead.
- You can ask specific questions on StackOverflow [gnome-shell-extensions]
Although it might be a little hard to get into it, the extension framework is quite powerful. Have fun!
Posted by Lukas Knuth