How to test / debug GNOME Shell extensions? Is there any tool for that?

JavascriptGnome 3Gnome ShellGnome Shell-Extensions

Javascript Problem Overview


I would like to develop GNOME Shell extensions and found it's really easy to step into the development process but I still can't figure out how to debug / test my extensions effectively.

Are there any tools for that purpose? Is there any kind of real time console like we have on modern browsers or javascript servers environments?

Javascript Solutions


Solution 1 - Javascript

Yes, the real-time console is called "Looking Glass" and can be started by pressing Alt+F2 and typing lg at the prompt.

More info: https://live.gnome.org/GnomeShell/LookingGlass

Solution 2 - Javascript

On Fedora 20 (and probably any new linux distro) you can use that command:

journalctl /usr/bin/gnome-session -f -o cat

It constantly (-f) prints errors generated by gnome-session in terminal window. I prefer -o cat flag as it shows full messages without timestaps.

On Fedora 22, I believe, it was replaced with:

journalctl /usr/bin/gnome-shell -f -o cat

Solution 3 - Javascript

Looking Glass is great. If you need a straight console, though, you can get one, but not through LG, at least not as of 3.6.

If you pop open a terminal and type gnome-shell --replace, gnome-shell will run from there, replacing the running instance, and global log output will thereafter appear in that console.

You can test it with Looking Glass by doing Alt-F2 lg, and thenglobal.log("foo") in the "Evaluator" tab.

Solution 4 - Javascript

I prefer reading ~/.xsession-errors and ~/.cache/gdm/session.log files for more detail. Some of the error messages might have a relation with other exceptions or errors.

Solution 5 - Javascript

The other answers didn't really work for me while developing my own extension. What did however was:

journalctl /usr/lib/gnome-session/gnome-session-binary -f -o cat 

If you want to declutter the output to just see your app, you can use:

journalctl /usr/lib/gnome-session/gnome-session-binary -f -o cat | grep [myAppId]

If you also want to access non error logs using the above method above you can use:

global.log('[myAppId]', valueToLog);

If you don't know the correct path to your gnome session you can also use:

journalctl -f | grep gnome-session

Why it was not working is probably because of my gnome-session-binary path was different, which might be related to a newer version of gnome being installed.

Solution 6 - Javascript

I can't comment on other answers yet, so thought I'd add - however late it may be:

  • For comment 2 of Geoff's answer, just restart the shell via alt+f2 - then r and enter, when that happens - the terminal-run session will end automatically (at least on Debian).

  • I'd recommend jsnjack's answer for general debugging, which works with Debian Jessy as well; probably want to sudo that though. It'll show gnome errors, as well as global.log() messages in whichever terminal you run it in.

If anything, this provides a more complete reference for me - as I've come across this page more than once when referencing info I don't keep fresh in my memory.

Solution 7 - Javascript

Anjuta Dev-Studio is a great tool for working with gnome-shell extensions; it comes equipped with a debugger, GUI designer, version control, and more. There's even a guided tutorial for using Anjuta with gnome-shell extension projects over on gnome's wiki-pages

Solution 8 - Javascript

We are developing a emacs package aimed at gnome-shell extension development here: https://github.com/paperwm/gnome-shell-mode

It's still in "beta" (dec. 2017), but its already very useful.

Features

  • Autocompletion (muuuch better than what looking glass provides)
  • Eval of line, selection, current function, buffer (optionally pasting the result into the buffer in a comment)
  • Highlight of error when evaling
  • Documentation lookup helper
  • Helper to reload the module you're working on without restarting gnome-shell

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionmarcioView Question on Stackoverflow
Solution 1 - JavascriptptomatoView Answer on Stackoverflow
Solution 2 - JavascriptjsnjackView Answer on Stackoverflow
Solution 3 - JavascriptGeoffView Answer on Stackoverflow
Solution 4 - JavascriptThe_Cute_HedgehogView Answer on Stackoverflow
Solution 5 - Javascripthugo der hungrigeView Answer on Stackoverflow
Solution 6 - JavascriptRikView Answer on Stackoverflow
Solution 7 - JavascriptILMostro_7View Answer on Stackoverflow
Solution 8 - JavascriptolejorgenbView Answer on Stackoverflow