You are not logged in.

#1 2021-10-26 09:14:06

AnantGupta
Member
Registered: 2021-07-11
Posts: 3

Linux: Setting power button to sleep instead of power off?

The current state of my power button is, that if I press it, it will shut down my PC. But, it is inconvenient for me, I want it to sleep instead of powering it off. How can I change this? These are some specs that might help.

Laptop Model: HP ProBook 440 G4

Window Manager: Dynamic-Window Manager (DWM)

Offline

#2 2021-10-26 09:21:05

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,153

Re: Linux: Setting power button to sleep instead of power off?

https://wiki.archlinux.org/title/Power_ … th_systemd

note that for these to work properly you need to initialize your session correctly so if you are using .xinitrc to start dwm you need to ensure you follow https://wiki.archlinux.org/title/Xinit#xinitrc as well.

Last edited by V1del (2021-10-26 09:22:26)

Offline

#3 2021-10-26 09:42:44

sabroad
Member
Registered: 2015-05-24
Posts: 242

Re: Linux: Setting power button to sleep instead of power off?

The ProBook has a sleep button on the keyboard: that's at least worth a try getting used to.


--
saint_abroad

Offline

#4 2021-10-27 03:15:54

AnantGupta
Member
Registered: 2021-07-11
Posts: 3

Re: Linux: Setting power button to sleep instead of power off?

I don't have such a sort of button...
My PC is borrowed, & I am telling the model name by the neofetch output

Offline

#5 2021-10-27 03:26:49

AnantGupta
Member
Registered: 2021-07-11
Posts: 3

Re: Linux: Setting power button to sleep instead of power off?

V1del wrote:

https://wiki.archlinux.org/title/Power_ … th_systemd

note that for these to work properly you need to initialize your session correctly so if you are using .xinitrc to start dwm you need to ensure you follow https://wiki.archlinux.org/title/Xinit#xinitrc as well.

Thanks, this is working!
I did `HandlePowerKey=suspend` in /etc/systemd/logind.conf
then did
`systemctl kill -s HUP systemd-logind`
After this, pressing power button is only suspending it

Offline

#6 2025-07-20 14:35:54

asklow
Member
Registered: 2022-11-07
Posts: 68

Re: Linux: Setting power button to sleep instead of power off?

Can HandlePowerKey=suspend be done at user level ? Caz GNOME was able to do within their settings. It somehow exposed that config to the user. Can it also be done in other DEs/WMs like when using sway ?

Offline

#7 2025-07-20 15:20:36

LinuxLover471
Member
From: Asia, India
Registered: 2025-02-23
Posts: 172

Re: Linux: Setting power button to sleep instead of power off?

Please add [Solved] to your subject so that others know there is nothing left to answer.


--- asyync1024

Offline

#8 2025-07-20 15:20:44

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,277

Re: Linux: Setting power button to sleep instead of power off?

No - and please don't necrobump.
gnome inhibits the event and does other stuff w/ its own acpi/shortcut daemon,  https://wiki.archlinux.org/title/Power_ … r_managers
Whether your shortcut daemon of choice handles the power key you'll have to figure.

Caz GNOME was …

"cuz" …

Edit:
@LinuxLover471
it's unlikely that the OP still frequents the forum, but the thread will likely be closed by some mod.

Last edited by seth (2025-07-20 15:21:40)

Offline

#9 2025-07-20 16:31:35

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,623

Re: Linux: Setting power button to sleep instead of power off?

Yeah, the OP has not been around for almost four years.  I am going to go ahead and close this.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

Board footer

Powered by FluxBB