zenUtils/sleepy.sh

25 lines
590 B
Bash
Raw Normal View History

#!/bin/sh
# this is a simple replacmeent for an ACPI handler script
# put it somewhere accessible for single-user mode and make a runit script for it
# copyleft 2020 Derek Stevens <drkste@zoho.com>
# MIT License -- do whatever you want
acpi_listen | {
while read event; do
# if no external monitor
# if [ ! -z "$(xrandr | grep HDMI | grep disconnected)" ]; then
# if AC is offline
if [ ! -z "$(acpi -a | grep off-line)" ]; then
if [ "${event}" = "button/lid LID close" ]; then
slock & sleep 1
zzz
fi
fi
# fi
done
}