My scripts is a combination of acpid script, tuxonice and hibernate-scripts. Changes are really minor
My default.sh has
Code: Select all
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
;;
where /etc/acpi/lidbtn.sh is
Code: Select all
#!/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
It uses a bit modified script from hibernate-scripts, I have a symlink /usr/sbin/hibernate-s2both
Code: Select all
/usr/sbin/hibernate-s2both -> /usr/sbin/hibernate
and use the property of hibernate scripts, that if you have a symlink with a "suffix", hibernate searches for a configuration file "suffix.conf" in /etc/hibernate directory. In my case it is "s2both.conf". This conf file is just a copy of tuxonice.conf, with one difference
Code: Select all
## Powerdown method - 3 for suspend-to-RAM, 4 for ACPI S4 sleep, 5 for poweroff
PowerdownMethod 3
tuxonice always writes and image to disk, as for hibernation, and now I instruct it after doing it not to hibernate, but suspend-to-RAM
One thing is, script relies on /proc interface which acpid starts to abandon. For now it still seems to work, however, deperetiated proc entries and directories are enabled in my kernel.