#!/bin/sh

grep -q closed /proc/acpi/button/lid/*/state

if [ $? = 0 ]

then
        . /usr/share/acpi-support/screenblank
        chvt 12

        # Unmount any NFS or SMB filesystems:
        umount -a -r -t nfs,smbfs

	# shutdown wireless card
	# ifdown wlan0

        # remove modules
        rmmod ehci-hcd   ## USB module
        rmmod uhci-hcd   ## USB module

        # update the disk super block
        sync

        # wait a second
        sleep 1

        # turn the LCD off
        radeontool light off

        # suspend to ram
        echo -n mem > /sys/power/state

        # load modules
        modprobe ehci-hcd
        modprobe uhci-hcd
 
        # turn the LCD on
        radeontool light on

        # go back to virtual term 7 (X)
        chvt 7
fi