Anyone have a script to toggle the Do Not Disturb option when a user logs in?
I'm open for other suggestions as well.
Anyone have a script to toggle the Do Not Disturb option when a user logs in?
I'm open for other suggestions as well.
Best answer by elliotjordan
My first draft. Feel free to steal/improve:
#!/bin/bash
# Gather the necessary variables
CURRENT_USER=$(/usr/bin/stat -f%Su /dev/console)
HARDWARE_UUID=$(system_profiler SPHardwareDataType | awk '/Hardware UUID: /{print $3}')
CURRENT_DATE=$(date -u +%FT%TZ)
# Modify the ByHost plist files
defaults -currentHost write "/Users/$CURRENT_USER/Library/Preferences/ByHost/com.apple.notificationcenterui" doNotDisturb -bool true
defaults -currentHost write "/Users/$CURRENT_USER/Library/Preferences/ByHost/com.apple.notificationcenterui" doNotDisturbDate -date "$CURRENT_DATE"
# Kill Notification Center for settings to take effect (it will automatically relaunch)
killall NotificationCenter
exit 0Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.