#!/bin/sh
# /etc/acpi/sleepbtn.sh
# Initiates a suspend when the sleep button has been pressed

#  Initial settings
exec >> /dev/null 2>&1
umask 0077
PATH="/sbin:/bin:/usr/sbin:/usr/bin"
# These are troublesome modules you wish to remove prior to suspending
MODULES=""

# Suspend
echo "Going to sleep at `date`"
echo -n "* remove modules:"
for i in $MODULES; do
	echo -n " $i"
	rmmod $i
done
echo ""
echo "* sending commands"
echo -n "shutdown" > /sys/power/disk
echo -n "disk" > /sys/power/state

# Resume
echo ""
echo "Back from sleep at `date`"
echo -n "* inserting modules:"
for i in $MODULES; do
	echo -n " $i"
	modprobe $i
done
echo ""
echo "* done"
echo ""

# Done
exit 0
