#!/bin/bash

###test -f /usr/sbin/laptop_mode || exit 0

# lid button pressed/released event handler

####/usr/sbin/laptop_mode auto

RUNLEVEL=`/sbin/runlevel | cut -c3`
if [ "$RUNLEVEL" == "6" ]; then
    RUNLEVEL=0
fi

if [ "$RUNLEVEL" == "0" ]; then
    echo "ignoring lid's request to suspend; system is shutting down."
    exit
fi

if grep -q on /proc/acpi/ac_adapter/AC/state; then
    echo "ignoring lid's request to suspend due to on-line power"
    exit
fi

if grep open /proc/acpi/button/lid/LID/state; then
    echo "ignoring strange request to suspend; laptop in use.";
    exit
fi

echo 3 > /proc/acpi/sleep



