You are not logged in.
Pages: 1
Hi,
I want hibernate my system when i will press power button. But it didn't working on acpid.
Here is my handler.sh:
#!/bin/bash
# Default acpi script that takes an entry for all actions
case "$1" in
button/power)
case "$2" in
PWRF) logger "PowerButton pressed: $2"
systemctl suspend;;
*) logger "ACPI action undefined: $2" ;;
esac
;;
button/sleep)
case "$2" in
SLPB|SBTN)
sleep 2 && systemctl suspend
;;
*)
logger "ACPI action undefined: $2"
;;
esac
;;
ac_adapter)
case "$2" in
AC|ACAD|ADP0)
case "$4" in
00000000)
logger 'AC unpluged'
;;
00000001)
logger 'AC pluged'
;;
esac
;;
*)
logger "ACPI action undefined: $2"
;;
esac
;;
battery)
case "$2" in
BAT0)
case "$4" in
00000000)
logger 'Battery online'
;;
00000001)
logger 'Battery offline'
;;
esac
;;
CPU0)
;;
*) logger "ACPI action undefined: $2" ;;
esac
;;
button/lid)
case "$3" in
close)
sleep 2 && systemctl suspend
;;
open)
logger 'LID opened'
;;
*)
logger "ACPI action undefined: $3"
;;
esac
;;
*)
logger "ACPI group/action undefined: $1 / $2"
;;
esac
# vim:set ts=4 sw=4 ft=sh et:
Suspend working for close lid and for sleep button, but not working for power button. Now if i press power button my system is shutdown.
Anybody know how fix it?
Offline
Do you have systemd ?
Last edited by teateawhy (2012-10-17 18:32:38)
Offline
see your
/etc/systemd/logind.conf
and
man logind.conf
for more help.
Never argue with stupid people,They will drag you down to their level and then beat you with experience.--Mark Twain
@github
Offline
yes, i am using systemd.
here is my logind.conf:
[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#Controllers=
#ResetControllers=cpu
#InhibitDelayMaxSec=5
HandlePowerKey=suspend
#HandleSuspendKey=suspend
#HandleHibernateKey=hibernate
#HandleLidSwitch=suspend
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
And still suspend not working if i press power button.
Offline
...
HandlePowerKey=suspend
....
did you really see the man page ?
Never argue with stupid people,They will drag you down to their level and then beat you with experience.--Mark Twain
@github
Offline
I don't think you really did your own research here. illusionist is right in that if you read the man page, you would have solved this yourself.
From the logind.conf man page
HandlePowerKey=, HandleSuspendKey=, HandleHibernateKey=, HandleLidSwitch=
Controls whether logind shall handle the system power and sleep keys and the lid
switch to trigger actions such as system power-off or suspend. Can be one of
ignore, poweroff, reboot, halt, kexec and hibernate. If ignore logind will never
handle these keys. Otherwise the specified action will be taken in the
respective event. Only input devices with the power-switch udev tag will be
watched for key/lid switch events. HandlePowerKey= defaults to poweroff.
HandleSuspendKey= and HandleLidSwitch= default to suspend. HandleHibernateKey=
defaults to hibernate.
If you don't know the possible settings, it seems a little rediculous to simply guess, then cry that it does not work as you had hoped.
Edit: added bold for emphasis... is it working?
Last edited by WonderWoofy (2012-10-20 14:18:17)
Offline
Ok, hibernate works.
BUT i don't understand one thing. What I should do if i will want suspend my computer if I press power button? And why default options of HandleLidSwitch = suspend?
Offline
I don't know why it indicates that in the logind.conf, maybe it is a mistake. I guess you would have to use some other method like acpid for more fine grained control. I have never tried to make my power button do anything but shut the computer down though. Acpid should make it stooopid simple though.
Offline
If that's right, the manual page is extremely misleading since the quote you gave clearly distinguishes suspend from hibernate and explicitly claims that these functions can handle suspend.
I've got a lot of these set to "ignore" as KDE/KDM wants to handle them. But it is at least bizarre if systemd logind supports hibernate but not suspend, isn't it? (I'm assuming suspend=sleep and hibernate=suspend-to-disk.)
CLI Paste | How To Ask Questions
Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L
Offline
The available options don't mention suspend, so I figured the powerkey does not do it. Maybe you are right though, since it obviously is a function of the lid switch.
I was referring to the fact that logind.conf is supposed to have the defualts listed and commented out, but it has #HandlePowerKey=suspend, which it does not, as my computer shuts down on the defaults. I never changed any because I figure they were pretty sane.
Offline
why default options of HandleLidSwitch = suspend?
Because this is the expected behavior of a laptop. You use it, and when you stop using it you close it, and it suspends. Then when you open it, it wakes up(some models don't wake up on their own, and you should press the power button). It is really convenient, when you want to save power during long periods away from a charger.
Offline
Pages: 1