I created an extension for gnome shell and want to be able to start it using a keyboard shortcut (something like ctrl+space). I didn't find good documentation or tutorials that helped me creating the extension in the first place and the ones i found did not mention keyboard shortcuts. The easiest workaround i can think of is writing a bash script that runs the extension and then map that script to a key shortcut. When i use gjs extension.js i get this:

(gjs:2929): Gjs-WARNING **: JS ERROR: Error: Requiring St, version none: Typelib file for namespace 'St' (any version) not found

JS_EvaluateScript() failed

As a prerequisite, the Gnome Shell Extension has to be installed where gnome-shell can find it. This is in

  • /usr/share/gnome-shell/extensions/ for system wide extensions (managed by your distro package manager)
  • $HOME/.local/share/gnome-shell/extensions/ for user extensions (this is where you put yours).

Then, to enable/disable the extension, use the gnome-shell-extension-tool with the -e and -d option. E.g. to enable the extension test@test, use

gnome-shell-extension-tool -e test@test

You can assign a keyboard shortcut to this command via the Gnome Control Center.

Having said that, that's probably not what you want to do. Rather, you should write the extension such that it is enabled all the time. Upon enabling, your extension should add a keybinding to gnome-shell via Main.wm.addKeybinding(). This keybinding triggers the desired action of your extension. For specifics on how to do this, seek help on stackoverflow, see the gnome-shell sourcecode or see the source code of other extensions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.