You are not logged in.

#1 2022-05-30 15:38:03

Brain
Member
Registered: 2020-07-29
Posts: 33

[SOLVED] How to remap the power-off button

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

#2 2022-05-31 09:56:27

koffeinfriedhof
Member
Registered: 2017-11-30
Posts: 72

Re: [SOLVED] How to remap the power-off button

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

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

#3 2022-05-31 20:16:24

Brain
Member
Registered: 2020-07-29
Posts: 33

Re: [SOLVED] How to remap the power-off button

I got it working with your tips!
Thank you very much.

Offline

Board footer

Powered by FluxBB