Open Application Launcher with Super key

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

  1. 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

  2. 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

  3. 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

  1. 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).
  2. You can use ksuperkey for any action, for example to open KRunner – just bind Alt+F1 to the action.
  3. 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 change XK_F1); to the key you want, e.g. XK_F2);. Recompile with make and you’re done.
  4. 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.

73 Responses to “Open Application Launcher with Super key”

  1. Fabi Says:

    already using ksuperkay, thank you 😀
    1question.. whats your windeko?

  2. Martin Gräßlin Says:

    > 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.

  3. Mikael Hermansson Says:

    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”

  4. Alexey D. Says:

    >ksuperkey is a very small application that lets you open the application launcher by pressing the left Super key

    Why? Just use xmodmap.

  5. Hans Says:

    @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.

  6. LXC Says:

    Awesome! I waited so long for this. Actually I’m using it now with Alt+F2 to start krunner 😉

  7. Oskar Hollmann (@OskarHollmann) Says:

    Thank you so much for this. It bugged me for so long… And there is already PKGBUILD in AUR, great.

  8. xav Says:

    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.

  9. anonymity is great Says:

    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.

  10. Hans Says:

    @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?

  11. Ade Malsasa Akbar Says:

    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.

  12. Hans Says:

    @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.

  13. Ade Malsasa Akbar Says:

    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.

  14. Hans Says:

    That’s a bug in the Classic Menu plasmoid: https://bugs.kde.org/show_bug.cgi?id=274914

  15. Ade Malsasa Akbar Says:

    Okay, how to fix it, Hans?

  16. Hans Says:

    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).

  17. Hans Says:

    @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.)

  18. Lewis Says:

    Left Super key for “Meta+…” (for other shortcuts) and right Super key for the application launcher. It is better than “ksuperkey”.

  19. Lewis Says:

    Ksuperkey kidnaps the “Alt + F1” shortcut.

  20. Hans Says:

    @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.

  21. AnonymousOne Says:

    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”.

  22. Instalar el lanzador Homerun desde código fuente y abrir el menú de KDE SC con la tecla Windows. | Pardus Life Says:

    […] 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 […]

  23. martijn Says:

    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?

  24. Thany Says:

    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))

  25. Hans Says:

    @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.

  26. oizzzo Says:

    Thanks, it works, and even other keys like Meta+D works after installing this.

  27. Thany Says:

    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).

  28. Thany Says:

    Oh, one more thing. Can you make it so that pressing the windows key a second time hides the laucher? Same as on windows 😉

  29. Hans Says:

    @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

  30. Thany Says:

    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.

  31. Hans Says:

    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.

  32. joon Says:

    Wow this is amazing. Just installed in my openSUSE and it works flawlessly. Thanks a lot.

  33. Hans Says:

    That’s good to hear, thanks for your comment joon.

  34. joon Says:

    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.

  35. Hans Says:

    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. 🙂

  36. Super Key in Kubuntu | Develop/mentally Says:

    […] 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, […]

  37. scra5071 Says:

    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.

  38. Hans Says:

    @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.

  39. Khariton Says:

    Why this one is better than pressing Alt+F2 in KDE4?

  40. Hans Says:

    @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.

  41. Linux Echoes Says:

    if I do the Alt+F1 it gvies to me a P
    I don’t know why

  42. Hans Says:

    @Linux Echoes:

    You mean in the terminal? Did you assign Alt+F1 to the application launcher widget as described in this post?

  43. Linux Echoes Says:

    It workks now, honestly…I don’t know what happened haha, well thaks for the help any way 😀

  44. Hans Says:

    No problem, glad to hear that it works!

  45. Gyges Says:

    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.

  46. Hans Says:

    @Gyges:
    Thanks! It’s comments like yours that keep me motivated to do it. 🙂

  47. Su B Says:

    Does not work most of the times. It only works when a KDE desktop or app is in focus.

  48. Su B Says:

    Wait, after reboot it works. But not sure how, cause I did not set it to autorun.

  49. Hans Says:

    @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.

  50. :) Says:

    Nice rep u got there ChenChen 😉

  51. zeird Says:

    Works perfectly. Thank you, Hans.

  52. Hans Says:

    Glad to hear that it’s working well for you zeird!

  53. Ade Malsasa Akbar Says:

    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.

  54. Hans Says:

    @Ade Malsasa Akbar:
    Great that it’s still working well for you! Thanks for taking the time to leave a comment here.

  55. Daniel Says:

    First: a big THANK YOU!
    Second: It also works with lubuntu if mapping is set to Control-Escape. Changing line 92:

        static char default_mapping[] = "Super_L=Control_L|Escape";
    

    did the trick 🙂

  56. KDE Plasma 5 und die Windowstaste | vinzv Says:

    […] 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 […]

  57. Hans Says:

    @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! 🙂

  58. ksuperkey 0.4 released | Who Says Penguins Can't Fly? Says:

    […] Open Application Launcher with Super key […]

  59. KDE Plasma 5 und die Windowstaste – vinzv Says:

    […] 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 […]

  60. Obsidian Jackal Says:

    For KDE 5, use “ksuperkey -e ‘Meta_L=Alt_L|F1′” instead of Super_L

  61. hylianux Says:

    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

  62. Joshua Allison Says:

    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.

  63. Hans Says:

    @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.

  64. Joshua Allison Says:

    Ok, thanks for the confirmation. One last thing, where can I find the Read.me?

  65. Hans Says:

    You can find the README either in the tar.gz when you download ksuperkey, or on Github: https://github.com/hanschen/ksuperkey/


Leave a comment