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-12-05 22:39:10 -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
|
|
|
|
echo "Going to sleep..."
|
2020-04-12 13:09:31 -07:00
|
|
|
systemctl suspend
|
2016-11-16 06:09:51 -08:00
|
|
|
else
|
2017-12-05 22:39:10 -08:00
|
|
|
echo "Shutting my eyes..."
|
2020-04-12 13:09:31 -07:00
|
|
|
if command -v slock >/dev/null; then
|
|
|
|
pgrep slock >/dev/null || slock &
|
|
|
|
fi
|
|
|
|
sleep 1
|
|
|
|
xset dpms force off
|
|
|
|
;;
|
2016-11-16 06:09:51 -08:00
|
|
|
fi
|