You are not logged in.
Hello.
I am running a window manager, not a desktop environment and I am trying to remap the power-off button to not power-off my computer, but rather run a script that asks me (via dmenu), whether I want to hibernate, shutdown or reboot.
I tried doing this with acpid and with polkit like this: https://unix.stackexchange.com/a/425393.
All major desktop environments seem to be doing it somehow.
So, how can this be done?
(I didn't really know where to post this...)
Last edited by Brain (2022-05-31 20:16:42)
Offline
Hi!
Which window manager are you running? How does it handle normal keys? The way is just the same as binding any other key to run a script.
First you have to disable systemds power key handling in /etc/systemd/logind.conf and set HandlePowerKey=ignore. Or you use it and create a unit triggered by poweroff.target.
You can get the event using libinput debug-events and pressing the button (after disabling instant powerdown )
In evdev the key is called <POWR>, in Kernel it is defined as KEY_POWER 116 if you need to bind it on tty.
Offline
I got it working with your tips!
Thank you very much.
Offline