Linux – Have certain keys pass through lockscreen

linuxscreen-lockx11xorg

I'd like to have certain keys (mainly media keys) reach my windowmanager even if my lockscreen is active. This way, I could control my media player even when my screen is locked.

As far as I can see, this is probably only possible if the screen locker supports this: Once the screen locker has grabbed the keyboard pointer away from the root window, there seems to be no way of receiving keypress events.

Does anyone know any screen lockers supporting such a thing? Or any other way of listening to keypresses while a lockscreen is active?

Thank a lot,

Lukas

Best Answer

I figured something out: listening for raw keypresses is possible even when the keyboard focus is grabbed away by a screen locker. The downside is that with raw keypresses, you have to manually track the state of the modifier keys, but that seems to work pretty well.

I built a small hotkey daemon based on this idea which allows to execute commands even while the screen is locked. If anyone is interested, you can find it here: https://github.com/tinloaf/lhkd