Posted on 11-29-2018 03:54 AM
Has anyone managed to apply the following setting from the terminal?
System Prefs > Notifications > Do Not Disturb > Check When the display is sleeping
Solved! Go to Solution.
Posted on 12-03-2018 07:19 AM
So it actually turns out trying to modify the UUID.plist file directly caused problems. The below is how I've now managed to fix the issue
loggedInUser=$(python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + " ");')
sudo -u ${loggedInUser} defaults -currentHost write com.apple.notificationcenterui dndEnabledDisplaySleep -bool YES
Posted on 11-29-2018 07:18 AM
You might have to tinker with a scalable/scriptiable solution b/c there seems to be a unique ID appended to the plist that preference is stored in. You can check against what you see on your machine...
sudo defaults write ~/Library/Preferences/ByHost/com.apple.notificationcenterui.0954B6FD-C914-51EF-8955-90DA3DC3AFCE.plist dndEnabledDisplaySleep -bool YES
Posted on 11-29-2018 08:43 AM
@sshort Out of Interest, did you already know that or how did you come upon that PLIST?
Posted on 11-29-2018 08:53 AM
@LewisB Any plists stored in the ByHost folder in ~/Library/Preferences/ have the Mac's UUID number appended to them, which is what that long string of numbers/letters is.
You can find your Mac's UUID by doing ioreg -rd1 -c IOPlatformExpertDevice | awk -F" '/IOPlatformUUID/{print $4}'
What that outputs should match with a plist in that folder as part of the name like shown above.
Posted on 11-29-2018 08:55 AM
Posted on 12-03-2018 07:19 AM
So it actually turns out trying to modify the UUID.plist file directly caused problems. The below is how I've now managed to fix the issue
loggedInUser=$(python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + " ");')
sudo -u ${loggedInUser} defaults -currentHost write com.apple.notificationcenterui dndEnabledDisplaySleep -bool YES
Posted on 12-21-2021 09:43 AM
Just a note for folks referred here by Box’ support article on File Provider Extensions: the invocation of Python in the example here will trigger user notifications unless the system has been configured to use an installed version of Python 3, as Apple is deprecating Python version 2 and will stop including it with macOS at some future point. You can avoid this by obtaining the logged-in user’s name this way:
loggedInUser=$( stat -f %Su /dev/console )