View previous topic :: View next topic |
Author |
Message |
Drkg4b n00b
Joined: 07 Aug 2006 Posts: 42 Location: Italy
|
Posted: Fri Jan 25, 2013 1:25 pm Post subject: Kill acpid first during shutdown |
|
|
Hi all,
when I shutdown my laptop I need to wait for acpid to be killed (which happens after a while) before closing the lid or it will suspend to ram. I was wandering if it is safe to add an explicit kill for acpid in the shutdown runlevel script or if there are other ways. _________________ No Star Can Light Our Way In This Life Of Dark And Fear |
|
Back to top |
|
|
dmpogo Advocate
Joined: 02 Sep 2004 Posts: 3267 Location: Canada
|
Posted: Fri Jan 25, 2013 8:57 pm Post subject: Re: Kill acpid first during shutdown |
|
|
Drkg4b wrote: | Hi all,
when I shutdown my laptop I need to wait for acpid to be killed (which happens after a while) before closing the lid or it will suspend to ram. I was wandering if it is safe to add an explicit kill for acpid in the shutdown runlevel script or if there are other ways. |
I went the other way, I have configured acpid so that it suspends to RAM on lid closing not immediately, but after 30 sec (or so) delay. This way it has time to shutdown, if I had called shutdown before slamming lid, and as well does not suspend if I open the lid right away after closer. The last is particularly important for me, since on lid closure my setup both suspends to RAM and writes hybernate image, so delay avoids unnecessary writes. |
|
Back to top |
|
|
Drkg4b n00b
Joined: 07 Aug 2006 Posts: 42 Location: Italy
|
Posted: Sat Jan 26, 2013 11:44 am Post subject: |
|
|
This is a very good idea I didn't thought of! Thank you, I'll check out how to delay the suspend to ram after closing the lid!
Thanks again! _________________ No Star Can Light Our Way In This Life Of Dark And Fear |
|
Back to top |
|
|
Drkg4b n00b
Joined: 07 Aug 2006 Posts: 42 Location: Italy
|
Posted: Wed Feb 06, 2013 1:45 pm Post subject: |
|
|
Here is my solution, thanks to your advice I wrote this
Code: | if [ "$(pidof shutdown)" ]; then
sleep 60
else
echo 'mem' > /sys/power/state
fi
|
Its very simple and maybe can be improved with something like
Code: | [[ ! $(pidof shutdown) ]] && echo 'mem' > /sys/power/state |
but I have not tested the last one. _________________ No Star Can Light Our Way In This Life Of Dark And Fear |
|
Back to top |
|
|
dmpogo Advocate
Joined: 02 Sep 2004 Posts: 3267 Location: Canada
|
Posted: Wed Feb 06, 2013 5:59 pm Post subject: |
|
|
Drkg4b wrote: | This is a very good idea I didn't thought of! Thank you, I'll check out how to delay the suspend to ram after closing the lid!
Thanks again! |
This is what I have in /etc/acpi/lidbtn.sh (on my machine lid open and lid closed produces the same ACPI event, so I have to check the current state)
Code: |
#!/bin/bash
lid_state=/proc/acpi/button/lid/LID/state
test -e $lid_state || exit 0
if grep -q closed $lid_state ; then
#Often, we shutdown or hibernate and then immediately close lid.
#Try to sleep to let these processes finish
sleep 30s
# Lid could have been open back during this wait
if grep -q closed $lid_state ; then
logger "lid closed -> suspending"
/usr/sbin/hibernate-s2both
fi
else
logger "lid opened -> resuming"
fi
|
which is activated as
Code: |
case "$group" in
button)
case $action in
power)
/sbin/shutdown -h -t 5 now
;;
# xset dpms force off
lid)
date >> /var/log/lid
echo $id >> /var/log/lid
echo $value >> /var/log/lid
cat /proc/acpi/button/lid/LID/state >> /var/log/lid
/etc/acpi/lidbtn.sh
;;
*) log_unhandled $* ;;
esac
|
|
|
Back to top |
|
|
Dr.Willy Guru
Joined: 15 Jul 2007 Posts: 547 Location: NRW, Germany
|
Posted: Thu Feb 07, 2013 8:27 pm Post subject: |
|
|
Well, I guess I'll add my solution too
Code: | lid)
case "$id" in
open) :;; # handled by hardware
close)
runlevel | {
read PREVLEVEL RUNLEVEL
case $RUNLEVEL in
# multi-user mode
2|3|4|5) echo mem > /sys/power/state ;;
# system halt | single user | reboot
0|1|6) :;;
esac
}
;;
*) log_unhandled $* ;;
esac
;; |
|
|
Back to top |
|
|
|