Systemd-logind - Understanding Power Button Options

Hi,
on my HP Elitedesk, the BIOS has the `Power Button Override

Hi,
on my HP Elitedesk PC, the BIOS has the Power Button Override set to 4 seconds which should do a poweroff on keeping the powerbutton down.

But I am editing the logind.conf drop in file so that

HandlePowerKey=hibernate #was poweroff
#HandlePowerKeyLongPress=ignore
#HandleRebootKey=reboot
#HandleRebootKeyLongPress=poweroff
#HandleSuspendKey=suspend
#HandleSuspendKeyLongPress=hibernate
#HandleHibernateKey=hibernate
#HandleHibernateKeyLongPress=ignore

OK, the hibernate action works for HandlePowerKey but what determines or how long is a HandlePowerKeyLongPress?

I turned off the Power Button Override in the BIOS as a test but HandlePowerKeyLongPress settings don’t seem to do anything but the PC STILL powers down after a 4 second button press.

Maybe not all motherboards/BIOS respects ALL logind.conf settings?

Thoughts?

I do no know what your BIOS option does, but on all systems I have seen for many years keeping power button pressed for 4 seconds would perform hard power off.

BIOS is not even aware of these settings and so can neither respect nor not respect them.

1 Like

@kitman Also not all Desktop Environments respect logind.conf either…

I installed tumbleweed as server only - no DE like KDE or XFCE etc. Does your comment about logind.conf still count?

@kitman Yes, it’s there, run the command loginctl. Did you remove the # in the line respective line in logind.conf?

Ah, ok it still counts then.

Not sure what I’m seeing here but I’ll read man loginctl tonight for details.

chris@elitedesk:~> loginctl
SESSION  UID USER  SEAT TTY   STATE  IDLE SINCE
      3 1000 chris      pts/0 active no        

1 sessions listed.
chris@elitedesk:~>

But it still doesn’t explicitly answer what time determines a HandlePowerKeyLongPress. But I get the impression it will vary with motherboards/BIOSs and that Power Button Override BIOS setting.

@kitman man 5 logind.conf, looks like it’s a udev power-switch tag…

UEFI settings apply. They can be overridden.

1. From Maintenance and Service Guide http://h10032.www1.hp.com/ctg/Manual/c06063157

Power Button Override (disable/4 sec/15 sec/30 sec)

Lets you disable or enable and select the number of seconds you have to hold down the power button for
it to force the system to power off. Default is ‘4 sec’.

2. systemd-logind.service monitors the button

Whenever the power button gets pressed the service takes action:

erlangen:~ # journalctl -b -u systemd-logind.service -o short-monotonic 
[   29.776410] erlangen systemd[1]: Starting User Login Management...
[   29.803675] erlangen systemd-logind[1076]: New seat seat0.
[   30.043603] erlangen systemd-logind[1076]: Watching system buttons on /dev/input/event4 (Power Button)
[   30.044031] erlangen systemd-logind[1076]: Watching system buttons on /dev/input/event3 (Power Button)
[   30.044055] erlangen systemd-logind[1076]: Watching system buttons on /dev/input/event1 (Logitech K540/K545)
[   30.049278] erlangen systemd[1]: Started User Login Management.
[   31.271026] erlangen systemd-logind[1076]: New session 2 of user sddm.
[   61.056594] erlangen systemd-logind[1076]: New session 4 of user root.
[  120.249222] erlangen systemd-logind[1076]: New session 6 of user karl.
[  120.330657] erlangen systemd-logind[1076]: Session 2 logged out. Waiting for processes to exit.
[  120.331024] erlangen systemd-logind[1076]: Removed session 2.
[ 3439.009549] erlangen systemd-logind[1076]: Power key pressed short.
[ 3439.282878] erlangen systemd-logind[1076]: The system will suspend now!
[ 3444.867414] erlangen systemd-logind[1076]: Operation 'sleep' finished.
[33466.796542] erlangen systemd-logind[1076]: Power key pressed short.
[33467.065285] erlangen systemd-logind[1076]: The system will suspend now!
[33471.549222] erlangen systemd-logind[1076]: Operation 'sleep' finished.
erlangen:~ # 

A short press puts infamous host erlangen to sleep. A long press will power off the host.

Page not found on my browser.

Yes I got the short press worked out via logind.conf. But I bet you have the Power Button Override still set to 4sec for the long press to function.

The link works. Try another browser.

The UEFI of infamous host erlangen has no such setting. There is no need for this. Anyway:

“I have a headless linux mint machine that I use for a file server and other things. It’s been working great for me for a few years, but there’s one issue - my cat likes to hang out on top of it, and when she climbs off and on she occasionally steps on the power button and shuts off the machine.”

More : Change Behavior of Linux Power Button - Super User

My link:

karl@erlangen:~> curl -I http://h10032.www1.hp.com/ctg/Manual/c06063157
HTTP/1.1 200 OK
Date: Wed, 06 Dec 2023 10:25:46 GMT
Server: Apache
Content-Location: c06063157.pdf
Vary: negotiate
TCN: choice
X-Frame-Options: SAMEORIGIN
ETag: "5dbd417005240;60bc884676fc0"
Accept-Ranges: bytes
Content-Length: 3073818
Cache-Control: max-age=86400
Expires: Thu, 07 Dec 2023 10:25:46 GMT
X-Content-Type-Options: nosniff
Content-Type: application/pdf
X-Varnish: 34286903
Age: 0
Via: 1.1 varnish (Varnish/6.0)
X-Varnish-Origin: g8t12113g.inc.hp.com
X-Cache: MISS
Connection: keep-alive

Your link:

karl@erlangen:~> curl -I https://h10032.www1.hp.com/ctg/Manual/c06063157
HTTP/1.1 404 Not Found
Date: Wed, 06 Dec 2023 10:25:55 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
ETag: "53f4d05916680"
Accept-Ranges: bytes
Content-Length: 64873
X-Content-Type-Options: nosniff
Content-Type: text/html

karl@erlangen:~>