Last active
September 6, 2023 09:01
-
-
Save rchernobelskiy/5986a3bc334bd2107ff7e34af254053a to your computer and use it in GitHub Desktop.
Discourage use of mac during off hours by putting it to sleep automatically once a minute if it's awake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if test $(date '+%H') -ge 22 || test $(date '+%H') -le 5; then | |
if expr $(date '+%M') % 2 && /usr/local/bin/brightness -l|grep -q 'active, awake, online'; then | |
cvol=$(osascript -e 'output volume of (get volume settings)') | |
#curb=$(brightness -l|tail -1|cut -d' ' -f4) | |
finishat=$(expr $(date '+%s') + 60) | |
while test $(date '+%s') -lt $finishat; do | |
#brightness 0 | |
osascript -e "set volume output volume 0" | |
pmset displaysleepnow | |
sleep 0.3 | |
done | |
osascript -e "set volume output volume $cvol" | |
#brightness $curb | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment