Created
August 25, 2019 09:05
-
-
Save stevenirby/0dc9ae8ed871ea1d792916254b5ea9c5 to your computer and use it in GitHub Desktop.
Mute MacOS when do not disturb is on and you're not using the computer.
This file contains hidden or 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 | |
# | |
# Fist check if do not disturb is on. | |
# Then check if screen is off, meaning you're not using the computer at that time. | |
# If do not disturb is on and you're not using the machine, mute the volume. | |
if [[ $(/usr/bin/defaults -currentHost read ~/Library/Preferences/ByHost/com.apple.notificationcenterui doNotDisturb) -eq 1 | |
&& `echo $(/usr/sbin/ioreg -n IODisplayWrangler | grep -i IOPowerManagement | perl -pe 's/^.*DevicePowerState\"=([0-9]+).*$/\1/')/4 | bc` -eq 0 ]]; | |
then | |
osascript -e "set Volume 0" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment