Lid close ubuntu hibernate

The following is designed to work EVEN if you have not logged into a desktop environment.

File name:
/etc/acpi/lidbtn.sh

#!/bin/sh grep -q open /proc/acpi/button/lid/LID/state && exit 0
killall mplayer
sudo hibernate


(TODO May be it is better to check for close state instead of open?)


/etc/acpi/events/lidbtn
event=button[ /]lid action=/etc/acpi/lidbtn.sh


Restart ACPI
service acpid restart
or
reboot