+bin/zzz: sleep pc or displays
This commit is contained in:
parent
bb983ccbca
commit
b5df4c151b
22
bin/zzz
Executable file
22
bin/zzz
Executable file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# If -f, then put computer to sleep.
|
||||||
|
# Otherwise, lock screen and turn off monitor.
|
||||||
|
|
||||||
|
if [[ $1 = -f ]]; then
|
||||||
|
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*)
|
||||||
|
pgrep slock >/dev/null || slock &
|
||||||
|
sleep 3
|
||||||
|
xset dpms force off
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
Loading…
Reference in a new issue