You are not logged in.
Pages: 1
Hello,
I have been trying to set a delay to the power button on my laptop (arch 6.6.25-1-lts / openbox). I have tried both logind and acpid, but obviously I am doing something wrong. The only thing I have been able to achieve is the delay after I touch the button. But it is not what I want. My goal is that the system is shut down only after I have been holding the power button pressed for 2-3 seconds.
Could somebody please give me some advice?
Thank you.
Offline
That's probably not gonna work.
The short press usually gets exposed to the OS, but the long press is done in HW and cuts power from the board - you cannot intercept that at all, but it will cause an (unclean) shutdown of the system.
https://en.wikipedia.org/wiki/XY_problem
Why are you trying to do this?
Offline
That's probably not gonna work....Why are you trying to do this?
Thanks for the reply.
I have touched the power button instead of the backspace a few times already, and the system shuts down immediately, which is quite irritating. So, if can't do otherwise, I'll probably change the poweroff function to suspend or hibernate.
Thanks again.
Offline
When you "touch" the power button, does the system shut down properly or does it just power down abruptly?
The tail of the system journal of the previous boot (sudo journalctl -b -1) should indicate the shutdown process, a controlled shutdown in response to the power button shows up there - otherwise the journal ends abruptly w/o any shutdown messages.
Offline
Again, thanks for the reply.
The system shuts down properly. I have already reassigned the power button to suspend, and I think it will do for me.
Thank you!
Offline
So it's indeed handled by logind - make sure acpid isn't running.
https://man.archlinux.org/man/core/syst … .conf.5.en
HandlePowerKey=ignore
HandlePowerKeyLongPress=poweroffdoes not do what you want? What happens instead?
nb. the overlaying structure, make sure no other setting for this is enabled/takes precendence.
Also I thing you'll have to restart the logind service to have this change apply.
Offline
I have tried
HandlePowerKey=ignore
HandlePowerKeyLongPress=poweroff
It shuts down the system after about 8 seconds. It is a bit too much. So I've changed it to
HandlePowerKeyLongPress=sleep 3 && poweroff
It did not change anything.
Offline
You cannot impact the delay of the long press - did the 8s press result in a clean shutdown or an immediate power loss?
(Ie. was it handled by systemd or the hard/firmware)
HandlePowerKeyLongPress=sleep 3 && poweroff
isn't a legal statement.
What you possibly could do would be to intercept the power key (short press) in acpid, sleep 3s, check whether the key is still pressed and then trigger "systemctl shutdown".
evtest --query /dev/input/event0 EV_KEY KEY_POWERmight come handy here (nb. that it's not necessarily event0, "evtest" prints you a list of event devices)
Offline
It was a clean shutdown. I will try what you suggest.
Thank you!
Offline
I give up. Thank you!
Offline
If you un-give up, post what you have, what it does and where you're stuck.
Offline
Post editedLast edited by an24 (2024-04-10 00:05:26)
Offline
Regarding "evtest --query /dev/input/event0 EV_KEY KEY_POWER", I went through every event (0-12) and it returned nothing.
It returns a return code (for sure) and that's either "0" if the key isn't pressed or > 0 (typically 1) if it is.
You can
evtest --query /dev/input/event0 EV_KEY KEY_POWER && echo fooIf event0 is the correct device and the key is pressed, it'll print "foo"
Please use [code][/code] tags. Edit your post in this regard.
cat: /proc/acpi/button/power/PWRBTN/state: No such file or directorymeans that entire approach isn't going anywhere and the takeaway is that
I always ask GPT how to do things
will only end up w/ you doing dumb things because chatGPT is an authorative bullshit generator. It's great at telling really eloquent nonsense, nonsense nevertheless.
Offline
... entire approach ... will only end up w/ you doing dumb things because chatGPT is an authorative bullshit generator.
Well, that may be true, but so far chatGPT has been quite helpful and useful. And polite. And it is exactly because of people like you I prefer using "bullshit generators."
Offline
I'm not "polite" because people get stupid ideas into their heads and unless you very explicitly tell them that it's stupid, even if you just leave a tiny bit of "well, that could probably be correct but…" they'll just insist on blindly running down that rabbit hole into a disaster.
It's your system, you can do whatever you want.
But chatgpt has - very politely, I'm sure - fed you misdirecting misinformation based on not understanding what it's talking about itfp.
Offline
Pages: 1