Nautilus extensions and keyboard shortcuts

Quick question. How can an extension add a keyboard shortcut for its NautilusMenuItem?

How does Sushi manage to activate the preview window when a user presses the spacebar?

What I would like to do is to open my extension’s annotations window every time a user presses Ctrl + Shift + A on a selection of files.


Sushi is not an extension. The spacebar shortcut is built-in.

I’m not aware of any way for extensions to assign themselves a keyboard shortcut.

I see unavoidable issues with conflicting shortcuts:

  • when nautilus adds a new keyboard shortcut for one of its built-in features, but an extension already uses the same keyboard combination;
  • when two extensions compete tor the same keyboard combination.

So, I’m inclined to say it’s not a good idea for extensions to set keyboard shortcuts by themselves.


Thank you for your answer. I had thought of the possibility of conflicting shortcuts. But that is easily solvable. An extension could request a shortcut to Nautilus. At that point, if

  • A newer version of Nautilus decides to assign that shortcut ==> Nautilus refuses to give it to the extensions (without generating errors – the extensions’ developers will eventually find another shortcut, if they feel like updating their code)
  • Two extensions ask for the same shortcut ==> Nautilus assigns that shortcut randomly to the first extension of the two loaded (the extensions’ developers will have to find an agreement at some point)

Everything should happen without generating errors, at most warning messages to the error stream.

Nautilus already wraps some GLib objects into its own Nautilus* flavors. It wouldn’t sound so strange to wrap also the GtkAccelGroup type into a NautilusAccelGroup type.


Yes, you can avoid runtime errors, and that’s not what I was worried about.

The resulting user experience is still bad if there are conflicting shortcuts.

But the user will have no idea about conflicting shortcuts. The user will only see is an extension that from one day to another stops offering a shortcut, and they will blame the extension’s developers for not updating their code to the latest version of Nautilus.

Also a shortcut is… a shortcut! It is not meant to be the only way a feature can be accessed. The extension will still work via other means.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.