#! /bin/sh
get_state() {
echo $(cat /proc/acpi/button/lid/LID0/state)
}
OLD_STATE=$(get_state)
while :
do
CUR_STATE=$(get_state)
if [ "$CUR_STATE" != "$OLD_STATE" ]; then
if echo $CUR_STATE | grep closed; then
betterlockscreen -l
fi
fi
OLD_STATE=$CUR_STATE
sleep 5
done