Many users want the Super key (also commonly called the Windows key and confused with the Meta key) to open the Application Launcher in KDE Plasma Desktop. At the time of writing 145 users have voted for the Brainstorm idea “Super key to load Application Menu” and there are 51 comments. A workaround has been around for a long time which involves remapping the Super key to a regular key, but then you lose the ability to use it for other keyboard shortcuts. Until now, that is. In this post I’ll write about how you can eat the cake and have it too.
Super (Tux!) key between Ctrl and Alt. Source: Flickr
Spoiler: If you don’t feel like reading, scroll down to “… called ksuperkey!” to find the solution.
People from the Windows world are used to opening the so-called Start menu by pressing the Windows key. In Linux the key is called Super and is regarded as a modifier key, similar to Ctrl and Shift. A modifier key, as the name suggests, modifies other keys when held down – for example,
A if you press the A key while holding down Shift.
Now imagine that you bind a shortcut to the Super key. Pressing Super would then invoke the shortcut, and you wouldn’t be able to use it as a modifier anymore. For people like me who rely heavily on the Super key – I use it to launch and control applications – we’re suddenly left with one extra key for the price of losing several key combinations. Quite a bad trade-off.
But there has to be a solution! In Windows you can use the Super key as a modifier as well, and from what I’ve read Unity and GNOME Shell also seem to have that functionality.
One way to work around the problem is to let the shortcut be invoked when you release, rather than press, the Super key. If you press another key before releasing Super, it’ll act as a modifier key instead of invoking the shortcut.
There’s already an application that does something similar called xcape, which maps Ctrl to Escape if you press and release it on its own (from the README: “If you don’t understand why anybody would want this, I’m guessing that Vim is not your favourite text editor “). Thanks to the nature of free and open-source software it was easier than pie to fork it and adopt it to the needs of KDE users.
… called ksuperkey!
ksuperkey is a very small application that lets you open the application launcher by pressing the left Super key, while still allowing the Super key to act as a modifier key. In other words, it won’t affect any of your current shortcuts.
How to make it work
- Install ksuperkey. You can download the source and some distro-specific packages from KDE-apps, but compiling the latest version is also straightforward. First install the dependencies, for example on Ubuntu-based systems:
sudo apt-get install git gcc make libx11-dev libxtst-dev pkg-config
On some systems you’ll also need to install the
build-essentialpackage (otherwise you’ll get the following error:
stdlib.h: No such file or directory). Then run the following commands in a terminal:
git clone https://github.com/hanschen/ksuperkey.git cd ksuperkey make ./ksuperkey
ksuperkey runs in the background so you won’t see it
- Make sure that the keyboard shortcut for your application launcher is set to Alt+F1 (this is what ksuperkey will send when you press and release the Super key on its alone). Right click on the application launcher icon → Application Launcher Settings → Keyboard Shortcut.
Checking that the shortcut for Application Launcher is set to Alt+F1
- Now pressing the Super key should open the application launcher! If you want this behavior every time you log in, you have to set ksuperkey to Autostart, for example in System Settings → Startup and Shutdown → Autostart → Add Program… → small Browse button → Select the ksuperkey application.
Add ksuperkey to Autostart
- It’s safe to move the ksuperkey directory to anywhere you want. If you’ve added it to Autostart in System Settings, don’t forget to update the “Command” field with the right path (or remove the old entry and add a new one).
- You can use ksuperkey for any action, for example to open KRunner – just bind Alt+F1 to the action.
- If you want to change the keys sent by ksuperkey to something else, e.g. Alt+F2, you can easily modify the source code. Open
xcape.cin a text editor (e.g. Kate), go to line 92 and change
XK_F1);to the key you want, e.g.
XK_F2);. Recompile with
makeand you’re done.
- ksuperkey works fine on other workspaces/window managers as well, although it will probably cause problems if the workspace already uses the Super key as a non-modifier key (Unity, GNOME Shell).
Why isn’t this the default behavior?
I bet a lot of people reading this now wonder, if Windows, Unity, and GNOME Shell can do this, why isn’t it configurable in KDE Plasma Desktop? Surely it’s possible, as demonstrated by ksuperkey and the other workspaces.
I don’t have enough technical knowledge to give a good answer, but here are some things to consider:
- Although I haven’t look at the source, I’m pretty sure that the Super key behavior when it’s pressed and released on its own is hard-coded in the other workspaces. KDE Plasma Desktop is very configurable – you can remove the application launcher, or have hundreds of them (although I would doubt your sanity if you do have that many) – so I doubt this is a solution.
- Making it possible to bind actions to modifier keys would probably require large changes in how keyboard shortcuts are handled in KDE software. I’m also unsure whether this is desirable since it seems to go against the very basics of how modifier keys should be used.
- ksuperkey uses Xlib directly. I don’t know if it’s possible to do something like this using Qt, the GUI toolkit most KDE software is built on.
To summarize, I wouldn’t count on this feature being implemented in the near future (but you never know!). For the time being you’ll have to bear with ksuperkey, which uses a staggering 380 kibibyte of RAM on my system.