helm/bin/zzz.sh

31 lines
750 B
Bash
Raw Normal View History

2016-11-16 06:09:51 -08:00
#!/usr/bin/env bash
# If -f, then put computer to sleep.
# Otherwise, lock screen and turn off monitor.
2017-01-03 00:44:35 -08:00
if [[ $1 = -h ]]; then
bin=${0##*/}
echo "Usage: $bin [-f]"
echo
echo " $bin # put display to sleep"
echo " $bin -f # put computer to sleep"
elif [[ $1 = -f ]]; then
2016-11-16 06:09:51 -08:00
echo "Going to sleep..."
case $OSTYPE in
darwin*) pmset sleepnow ;;
linux*) systemctl suspend ;;
esac
else
echo "Shutting my eyes..."
case $OSTYPE in
darwin*) sleep 1; pmset displaysleepnow ;;
linux*)
2016-12-17 00:10:23 -08:00
if command -v slock >/dev/null; then
pgrep slock >/dev/null || slock &
fi
sleep 1
2016-11-16 06:09:51 -08:00
xset dpms force off
;;
esac
fi