Show panel while a modifier key is pressed (like swaybar)

Hi everyone,

is there a way to setup a KDE panel so it autohides (or is completely hidden), but is shown as soon as a modifier key (super) is pressed (on key-down, not on key-up), and (less important) hides again as soon as it’s released (like sway-bar with `mode hide` set)?

Setting the panel to autohide, and the custom shortcut for “Move keyboard focus between panels” to “Meta” is almost what I want: that toggles the panel when the super key is *released* - I want it to show when it’s *pressed* (and ideally hide when it’s released, but that’s less important to me).

I guess it’s not possible to set this up using the regular keyboard shortcut settings, but maybe someone has scripted something like this or any ideas how to go about that…?

I noticed the “Focus shortcut” set on Panel settings triggers on KeyDown, but it doesn’t allow me to use just “Meta” as shortcut, but only a key combination.

That seems to be a known bug though https://bugs.kde.org/show_bug.cgi?id=487682

However that seems to be a dead-end, because if I edit ~/.config/plasma-org.kde.plasma.desktop-appletsrc manually, to set the shortcut to just “Meta”, it kinda works - but it’s only triggering on KeyUp again.

Okay, the code shared in the article shared in this discuss post works for showing/hiding the panel:

let panel = panelById(401);

panel.hiding === "autohide" ? panel.hiding = "windowsgobelow" : panel.hiding = "autohide";

Now I just need to find out how to do something on global keydown/keyup events (as the regular shortcut facility only allows KeyUp).

I solved my problem by creating a plugin for KWin:

It’s just a few lines of C++, registering as an InputEventSpy and handling the keyboardEvent callback. The action I take is hard coded, sending a DBus message to PlasmaShell to show or hide the panel.

It’s derived from the example EventListener plugin in the KWin source tree: examples/plugin/eventlistener.cpp · master · Plasma / KWin · GitLab