You are not logged in.

#1 2022-08-11 18:26:50

Shyden
Member
Registered: 2022-02-18
Posts: 13

[SOLVED] logind.conf issues. (long press shutdown)

In an attempt to reduce the amount of times I shut down my laptop while carrying it, I changed my logind.conf from the default of

HandlePowerKey=poweroff

to

HandlePowerKey=ignore
HandlePowerKeyLongPress=poweroff

however this has caused issues.

When I do a log press on my power key, instead of running systemd-shutdown, it just cuts power (afaict). I used htop to look at PID 1 as I held the power key and it did not change from /sbin/init to /usr/lib/systemd/systemd-shutdown as the man page for systemd-poweroff.service says it should. My screen also does not change from my i3 to the way shutdown should look (I'm not sure how to describe it other than text).

I have read through the wiki page for power management as well as multiple man pages related to poweroff and shutdown such as systemd-poweroff.service and systemd-halt.service (they are the same). I have also read the files for halt, reboot, poweroff and shutdown.target (though I didn't understand them well). I've gone through stackoverflow and whatnot to no avail. If anyone could offer help, it would be much appreciated.

Thanks,
        Shyden

Edit: after thinking further I think its the actual hardware in my pc doing the shutoff, and systemd doesnt recognize HandlePowerKeyLongPress=poweroff. Is there anything I need to do other than add the line in logind.conf? It could also be that my hardware press length is shorter than the timeout for a "long press." Would anyone know how I could change that timeout (cannot find on man pages)?

Last edited by Shyden (2022-08-12 18:30:39)

Offline

#2 2022-08-11 22:37:41

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 68,608

Re: [SOLVED] logind.conf issues. (long press shutdown)

If you press the power key long enough, at some point the hardware will take over and power off the system: hard (no shutdown no nothing, this is necessary in case of eg. a kernel halt on linux, windows or any OS)
No idea what systemd is trying to achieve here, but the changelog says

* systemd-logind gained new settings HandlePowerKeyLongPress=,
          HandleRebootKeyLongPress=, HandleSuspendKeyLongPress= and
          HandleHibernateKeyLongPress= which may be used to configure actions
          when the relevant keys are pressed for more than 5s. This is useful
          on devices that only have hardware for a subset of these keys. By
          default, if the reboot key is pressed long the poweroff operation is
          now triggered, and when the suspend key is pressed long the hibernate
          operation is triggered. Long pressing the other two keys currently
          does not trigger any operation by default.

and for many devices the "long" press that's handled by the HW is just 4-5 seconds (so precedes or coincidents w/ the system timeout) - you may be able to configure that in the BIOS.
In any event you can measure the timeout with a stop watch, if it's < 5 seconds, you'll have to bring a custom event daemon.

https://debianforum.de/forum/viewtopic.php?t=183021 has a python implementation (german debian forum, so the debug output is german, but it's not complicated and the code is simple enough - either way: "kurz" means "short" and "lang" means "long")

Offline

#3 2022-08-12 18:29:56

Shyden
Member
Registered: 2022-02-18
Posts: 13

Re: [SOLVED] logind.conf issues. (long press shutdown)

Alright, it seems as though my laptop has about a 4.5 second time to a force off, so I'm going to have to look into the second option. Thanks for your help smile

Offline

Board footer

Powered by FluxBB