Change the behavior of super key alone

I want to know whether there is a way to use super(win) key alone as shortcut without change its function as a modifier.

On ubuntu, by default, pressing and then releasing super key, without pressing other keys, will invoke activity overview. But I want it to invoke a shell script written by me. And when super key and other key are pressed simultaneously, I want it to function as before.

I know how to disable super key from invoking activity overview in dconf-editor, but I do not know how to remap it.

Asked By: Simon


You can indeed put pressing and releasing Super to your own use with a utility like xcape (present in the default Ubuntu repositories) or ksuperkey.

You first need to disable the default assignment of Super in Gnome Shell:

gsettings set org.gnome.mutter overlay-key ''

Then you can use xcape to redirect pressing and releasing Super alone to a regular shortcut key combination, in particular the regular keyboard combination you use to launch your script.

For example, suppose we want Super to display the application overview. That action is already bound to Super+a, so to achieve that, we autostart the following command on login:

xcape -e "Super_L=Super_L|a"  #Load 

For your custom script, assign it a regular shortcut first using "Settings – Keyboard Shortcuts" and substitute Super_L|a by that shortcut key.

To undo, disable the autostart command and reset the dconf key to default with the command gsettings reset org.gnome.desktop.wm.keybindings panel-main-menu.

Answered By: vanadium