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.
The problem
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
becomes 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 – were 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.
A solution…
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 Linux-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-essential
package (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
Tips
- 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.c
in a text editor (e.g. Kate), go to line 92 and changeXK_F1);
to the key you want, e.g.XK_F2);
. Recompile withmake
and 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.
Update August 17, 2016: Updated links to point to Linux-apps.org instead of the old KDE-apps.org.
October 17, 2012 at 18:35
already using ksuperkay, thank you 😀
1question.. whats your windeko?
October 17, 2012 at 18:49
> The simple answer is “because it hasn’t been implemented”.
This is actually wrong, it had been implemented. I once stumbled upon a commit to remove the support again, because it was a hack and quite broken.
October 17, 2012 at 19:17
Its windows ugly key that is bad behave. Isnt the “SuperKey” really a META key on old keyboard?
layout was :
ALT | META | CTRL | Space | ALTGR | ….
Then came Microsoft “hey we introduce OUR key”
October 17, 2012 at 19:27
>ksuperkey is a very small application that lets you open the application launcher by pressing the left Super key
Why? Just use xmodmap.
October 17, 2012 at 19:44
@Fabi:
> 1question.. whats your windeko?
I use xmonad so I don’t really have a window decoration, just a border.
@Martin Gräßlin:
I seem to remember that it was available in KDE3, but I guess it was hard-coded back then? Anyway, I’ve removed that sentence, thanks for the correction!
@Alexey D.:
Because it breaks all other keyboard shortcuts with Super as a modifier key, as mentioned in the first paragraph.
October 17, 2012 at 20:22
Awesome! I waited so long for this. Actually I’m using it now with Alt+F2 to start krunner 😉
October 18, 2012 at 10:04
Thank you so much for this. It bugged me for so long… And there is already PKGBUILD in AUR, great.
October 18, 2012 at 11:49
just a silly question : would it be possible to have this behavior (modifier + regular key) for all the keys ? we surely have already a lot of shortcuts, but one can imagine that Q+W would be a desirable shortcut or that hitting CTRL would trigger the browser.
October 18, 2012 at 13:18
I am reading this in Akregator. In Akregator (and also in Konqueror) pressing “Ctrl” and releasing it activates “Access Keys”. If this behavior can be implemented for the Ctrl key, then I suppose that it should also be possible to implement it for the Super key.
Martin is right: support for the Super key to work on its own has been removed at the transition from KDE3 to KDE4, I remember discussions about that decision in which it was explained that the decision was made because the implementation was a hack and because modifier keys should only have one purpose, namely to be a modifier key and nothing else. Personally I prefer to have this feature back, even if it breaks the concept of being only a modifier key.
October 18, 2012 at 14:26
@LXC:
Glad to hear that you like it!
@Oskar Hollmann:
It’s actually my first PKGBUILD in AUR, so keep your kittens safe. 😉
@xav:
Sure you can easily do that for other modifier keys, look at line 214 in xcape.c. You probably don’t want to turn regular keys into such half-modifier-half-regular keys though, since then they would send the keycode on release, which could be quite annoying. For example, pressing the “A” key wouldn’t input “a” until your released it.
@anonymity is great:
Probably, yes. I still believe it’s easier to hard-code it than to use the current shortcut system in KDE Software (I think it’s called Input Actions?). Do you know if the behavior in KDE3 was configurable?
October 19, 2012 at 20:43
Ah, the end…
For so long time I’ve been wating for this hack. But how if I wanna install it not from Git? I wanna install it offline, or with Synaptic. Can I? Thank you, Hans.
October 19, 2012 at 23:34
@Ade Malsasa Akbar:
You can download the source from the KDE-apps page: http://kde-apps.org/content/show.php/ksuperkey?content=154569 (or do a git clone and copy the directory to a USB drive or something similar). There’s also a .DEB package for Ubuntu users, but I haven’t tried it myself since I personally use Arch.
October 21, 2012 at 11:21
Submit bug:
When I change menu style to classic, I can only open the menu with Win Key. Pressing Win key again does not close the menu.
October 21, 2012 at 12:58
That’s a bug in the Classic Menu plasmoid: https://bugs.kde.org/show_bug.cgi?id=274914
October 24, 2012 at 3:32
Okay, how to fix it, Hans?
October 24, 2012 at 13:12
Someone would have to fix the Classic Application Launcher plasmoid. I haven’t looked at the source myself, so I don’t know what exactly is required, but it should be fairly straightforward (if you’re interested in doing it I recommend that you take a look at the Kickoff source code).
October 27, 2012 at 17:33
There is other solution:
http://translate.google.com/translate?u=http%3A%2F%2Fmasquepeces.com%2Fwindousico%2F2012%2F08%2Fasignar-teclas-de-acceso-rapido-en-kde%2F&sl=es&tl=en&hl=en&ie=UTF-8
(Read the final section)
October 28, 2012 at 22:49
@Lewis:
Similarly to the xmodmap suggestion, can you still use the Super key for other shortcuts (Super+F for example) if you do that? I suspect the answer is “no” since the solution is basically the same. (I tried it but couldn’t get it to work, it still interpreted Meta as a modifier key, so I probably did something wrong.)
October 29, 2012 at 17:54
Left Super key for “Meta+…” (for other shortcuts) and right Super key for the application launcher. It is better than “ksuperkey”.
October 29, 2012 at 18:05
Ksuperkey kidnaps the “Alt + F1” shortcut.
October 29, 2012 at 23:40
@Lewis:
Aha. I don’t see how it’s better (some people use both Super keys, certain laptop models don’t have a right Super key, you may be used to pressing the left Super key, etc.), but well, each to their own. As explained in the original post (under “Tips”) you can change ksuperkey to send any key combination, e.g. Alt+F12.
November 16, 2012 at 0:18
The easiest alternative is to map the application launcher hotkey to “Super+Z”, rather than installing any third party application to make it work. The difference isn’t that so much from “Super” to “Super+Z”.
November 16, 2012 at 18:05
[…] para abrir el menú, pero sin perder la capacidad de usarla para nuestros atajos de teclado. Esto lo debemos al usario Hans (No me sé el apellido) que desarrollo un pequeño script para lograrlo. Para instalarlo sigue […]
January 25, 2013 at 17:42
martijn@martijn-VirtualBox:~/ksuperkey$ make
cc -Wall `pkg-config –cflags xtst x11` -o ksuperkey xcape.c `pkg-config –libs xtst x11` -pthread
/bin/sh: 1: pkg-config: not found
/bin/sh: 1: pkg-config: not found
xcape.c: In function ‘handle_key’:
xcape.c:288:29: warning: ‘XKeycodeToKeysym’ is deprecated (declared at /usr/include/X11/Xlib.h:1695) [-Wdeprecated-declarations]
/tmp/ccKmM0ng.o: In function `main’:
xcape.c:(.text+0x1b8): undefined reference to `XOpenDisplay’
xcape.c:(.text+0x1c9): undefined reference to `XOpenDisplay’
xcape.c:(.text+0x1f5): undefined reference to `XQueryExtension’
xcape.c:(.text+0x23c): undefined reference to `XRecordQueryVersion’
xcape.c:(.text+0×292): undefined reference to `XkbQueryExtension’
xcape.c:(.text+0x38f): undefined reference to `XRecordAllocRange’
xcape.c:(.text+0x3d6): undefined reference to `XRecordCreateContext’
xcape.c:(.text+0×428): undefined reference to `XSync’
xcape.c:(.text+0x44b): undefined reference to `XRecordEnableContext’
xcape.c:(.text+0×492): undefined reference to `XRecordFreeContext’
xcape.c:(.text+0x4c4): undefined reference to `XCloseDisplay’
xcape.c:(.text+0x4d3): undefined reference to `XCloseDisplay’
/tmp/ccKmM0ng.o: In function `sig_handler’:
xcape.c:(.text+0x5a7): undefined reference to `XRecordDisableContext’
xcape.c:(.text+0x5e8): undefined reference to `XSync’
/tmp/ccKmM0ng.o: In function `handle_key’:
xcape.c:(.text+0×898): undefined reference to `XKeycodeToKeysym’
xcape.c:(.text+0x8a0): undefined reference to `XKeysymToString’
xcape.c:(.text+0x8e0): undefined reference to `XTestFakeKeyEvent’
xcape.c:(.text+0×953): undefined reference to `XTestFakeKeyEvent’
xcape.c:(.text+0x9a0): undefined reference to `XFlush’
/tmp/ccKmM0ng.o: In function `intercept’:
xcape.c:(.text+0xb36): undefined reference to `XkbKeycodeToKeysym’
xcape.c:(.text+0xb98): undefined reference to `XRecordFreeData’
/tmp/ccKmM0ng.o: In function `parse_token’:
xcape.c:(.text+0xbfb): undefined reference to `XStringToKeysym’
xcape.c:(.text+0xc70): undefined reference to `XStringToKeysym’
xcape.c:(.text+0xcb5): undefined reference to `XKeysymToKeycode’
collect2: error: ld returned 1 exit status
make: *** [ksuperkey] Error 1
Clean Kubuntu on VirtualBox. I followed your instructions to the letter. Are you sure you didn leave something out that I needed to do?
January 25, 2013 at 17:46
FYI, Gnome ca NOT do this. Yes, it can open the start menu when pressing the windows key, but it can EITHER do that, OR use it as a modifier. Not both. Windows can do both, and so can ksuperkey (when the make command works (see above))
January 25, 2013 at 19:27
@martijn:
Apparently XKeycodeToKeysym has been deprecated, try the version I just uploaded to KDE-apps (or pull/clone from Github).
@Thany:
Thanks for the information, that’s nice to know. Do you know anything about Unity? I’m pretty sure it can do both as well.
January 28, 2013 at 7:34
Thanks, it works, and even other keys like Meta+D works after installing this.
February 1, 2013 at 13:30
Almost 🙂
All that is needed in addition was the package “pkg-config”. Just install via apt-get. If you update the instructions, it will work (and shouldn’t hurt if youǘe already got this pkg).
February 1, 2013 at 13:33
Oh, one more thing. Can you make it so that pressing the windows key a second time hides the laucher? Same as on windows 😉
February 1, 2013 at 13:42
@Thany:
Great that you figured that out. I added it to the README file and KDE-apps page, but forgot to update this blog post. Now I’ve added pkg-config to the apt-get command.
Hiding the launcher on a second keypress is something that should be handled by the widget itself. It works for the default launcher (Kickoff), but not for “Application Launcher Menu”. Here’s a bug report about it: https://bugs.kde.org/show_bug.cgi?id=274914
February 1, 2013 at 14:19
And as it so happens, the “Application Launcher Menu” is the default laucher in Kubuntu 12.10 😉
I’ll look into it. Maybe there’s a tweak or something.
February 1, 2013 at 14:29
Oh, I didn’t know that. It should be fairly easy to fix, but I personally don’t have any motivation to do it. I’m also not sure if the classic menu-style launcher has been/is going to be ported to QML.
February 20, 2013 at 0:39
Wow this is amazing. Just installed in my openSUSE and it works flawlessly. Thanks a lot.
February 20, 2013 at 0:43
That’s good to hear, thanks for your comment joon.
February 20, 2013 at 0:55
Actually I did not realize that you were the author of the ksuperkey. REALLY thanks a lot. 🙂 I love KDE in general but this has been the most annoying thing about it. In fact I randomly searched for this issue because my left elbow was hurting today after hitting Ctrl + Space (which I have been using for the launcher shortcut) all day.
February 20, 2013 at 1:00
Most of the credits should go to the author of the original program, xcape, I just modified it slightly to suit the needs of KDE users. Well, that just shows the power of free and open source software, I suppose. 🙂
March 27, 2013 at 7:40
[…] discussion about this since 2009, and the outcome is yet unclear. For the time being, Hans at hanschen.org has created ksuperkey. It is a very small & simple tool which you add to your startup setting, […]
March 31, 2013 at 14:39
I’m having trouble installing. When i get to the make line I receive the following:
george@George-Linux-Mint-14 ~/ksuperkey $ make
cc -Wall `pkg-config –cflags xtst x11` -o ksuperkey xcape.c `pkg-config –libs xtst x11` -pthread
xcape.c:22:20: fatal error: stdlib.h: No such file or directory
compilation terminated.
make: *** [ksuperkey] Error 1
Any help would be appreciated.
March 31, 2013 at 15:25
@scra5071:
I just helped another user with a similar problem, it seems that you need to install the
build-essential
package:sudo apt-get install build-essential
I’ll add a comment about it in the README. Hope that helps.
April 26, 2013 at 9:18
Why this one is better than pressing Alt+F2 in KDE4?
April 26, 2013 at 10:23
@Khariton:
It’s not necessary better, some people just prefer it to work this way, likely because a) you only need to press one key, and b) they’re used to it from e.g. Windows.
It is, however, better than the common solution to remap Super_L using xmodmap since you can still use Super_L as a modifier key if you use ksuperkey.
May 8, 2013 at 22:26
if I do the Alt+F1 it gvies to me a P
I don’t know why
May 8, 2013 at 22:41
@Linux Echoes:
You mean in the terminal? Did you assign Alt+F1 to the application launcher widget as described in this post?
May 8, 2013 at 23:39
It workks now, honestly…I don’t know what happened haha, well thaks for the help any way 😀
May 8, 2013 at 23:58
No problem, glad to hear that it works!
May 10, 2013 at 8:55
Thank you so much for your effort! Especially for doing it without using it yourself, you’re my Foss hero of the day!
Compiles and works great on Sabayon, just had to install pkg-config before.
May 10, 2013 at 12:45
@Gyges:
Thanks! It’s comments like yours that keep me motivated to do it. 🙂
May 14, 2013 at 8:51
Does not work most of the times. It only works when a KDE desktop or app is in focus.
May 14, 2013 at 8:59
Wait, after reboot it works. But not sure how, cause I did not set it to autorun.
May 14, 2013 at 19:40
@Su B:
The first issue sounds very strange; ksuperkey is not specific to KDE software at all. For your second question, how did you install the application? If you used the Ubuntu package it will add it to autostart automatically.
June 8, 2013 at 22:31
Nice rep u got there ChenChen 😉
August 18, 2013 at 5:06
[…] https://blog.hanschen.org/2012/10/17/open-application-launcher-with-super-key/ […]
May 15, 2014 at 0:22
Works perfectly. Thank you, Hans.
May 16, 2014 at 0:40
Glad to hear that it’s working well for you zeird!
September 30, 2014 at 15:07
[…] https://blog.hanschen.org/2012/10/17/open-application-launcher-with-super-key/ […]
October 6, 2014 at 7:08
I am still using your KSuperkey in this 2014. I always use it since the first time I saw it on KDE Forum. It was one of the most useful hacks for KDE I ever know. It is very useful. I wanna say thank you.
October 6, 2014 at 9:03
@Ade Malsasa Akbar:
Great that it’s still working well for you! Thanks for taking the time to leave a comment here.
March 8, 2015 at 15:07
First: a big THANK YOU!
Second: It also works with lubuntu if mapping is set to Control-Escape. Changing line 92:
did the trick 🙂
March 11, 2015 at 4:46
[…] راهنماش اینجاست […]
March 21, 2015 at 5:29
[…] dann durch Tippen nach Programmen suchen) gewöhnt. Unter KDE Plasma 5 lässt sich das mit einem kleinen Programm von Hans Chen recht einfach nachbauen: ksuperkey biegt kurz gesagt das durch Super ausgelöste Signal so um, dass […]
May 22, 2015 at 7:02
[…] Sumber: https://blog.hanschen.org/2012/10/17/open-application-launcher-with-super-key/ […]
June 24, 2015 at 4:08
@Daniel:
Thanks for your comment, and sorry about the late reply. You can achieve the same thing using the
-e
flag when starting ksuperkey, e.g.ksuperkey -e 'Super_L=Control_L|Escape'
No recompilation needed! 🙂
August 26, 2015 at 8:34
[…] Open Application Launcher with Super key […]
March 15, 2016 at 11:23
[…] dann durch Tippen nach Programmen suchen) gewöhnt. Unter KDE Plasma 5 lässt sich das mit einem kleinen Programm von Hans Chen recht einfach nachbauen: ksuperkey biegt kurz gesagt das durch Super ausgelöste Signal so um, dass […]
April 25, 2016 at 0:25
For KDE 5, use “ksuperkey -e ‘Meta_L=Alt_L|F1′” instead of Super_L
April 28, 2016 at 12:19
Copying my comment here… For those of us on CentOS (I used CentOS 7), 2 of the dependencies listed cannot be found: libx11-dev and libxtst-dev. Their package manager instead recognizes libX11-devel and libXtst-devel respectively. So, to translate that instruction to CentOS, here’s the command you need to run to get all the dependencies you need:
sudo yum install git gcc make libX11-devel libXtst-devel pkg-config
December 4, 2016 at 1:14
[…] https://blog.hanschen.org/2012/10/17/open-application-launcher-with-super-key/ […]
December 15, 2017 at 18:15
Because ksuperkey is running in the background, will it affect the computer system as far as memory usage and processing?
I work with old devices running Kubuntu 14.4 lts and didn’t want the systems to be slowed down. I’ve installed this on my current desktop with no problem using the ksuperkey_0.4-oppa0-trusty_i386.deb file and added it to the Autostart KDE- control Module. This is one rare useful program that, so far, works really good.
December 15, 2017 at 22:28
@Joshua Allison:
On my system ksuperkey currently takes up about 372 K memory, which is completely negligible (compared with e.g. the ~1,148,000 K that Firefox is currently taking). I don’t think you need to worry about slow downs due to ksuperkey, even on older devices.
December 15, 2017 at 22:46
Ok, thanks for the confirmation. One last thing, where can I find the Read.me?
December 19, 2017 at 10:33
You can find the README either in the tar.gz when you download ksuperkey, or on Github: https://github.com/hanschen/ksuperkey/
February 3, 2022 at 13:44
[…] 출처 […]
September 19, 2022 at 1:41
[…] source […]