Do Not Disturb

When I switch on ‘Do Not Disturb’ on my Mac, I still hear the incoming mail sound when new mail arrives. Is this caused by SpamSieve? Is it possible for it not to make the sound when ‘Do Not Disturb’ is set?

Martin

You can turn off the SpamSieve sound if you want. Unfortunately, macOS does not have a way for apps to tell whether Do Not Disturb is active.

Is this still the case? I’m a little surprised that macOS doesn’t suppress notifications during “do not disturb” focus without needing apps to implement it.

It is still the case that macOS does not offer an API for apps to tell when Do Not Disturb is in effect.

It does, but the Apple Mail and SpamSieve sounds for new mail are not notifications. If you turn off the sounds and only use notifications they will follow DND.

It looks like this returns the current state, so would a shell script or AppleScript be able to mute/unmute SpamSieve based on this?

defaults read com.apple.controlcenter “NSStatusItem Visible FocusModes”

From what I can see, that tells you whether a focus is in effect but not necessarily whether it’s the Do Not Disturb focus. If that works for your purposes, you could use a script to toggle SpamSieve’s sound setting:

defaults write com.c-command.SpamSieve PlaySound YES
defaults write com.c-command.SpamSieve PlaySound NO
1 Like

I’ll give that a shot. Thanks!

This seems to be working for me for DND and Sleep focus. I added this to my crontab (with crontab -e) and it runs every ten minutes, in case anyone finds it useful:

*/10 * * * * defaults read com.apple.controlcenter "NSStatusItem Visible FocusModes" | perl -ne 'chomp;if($_){system("defaults write com.c-command.SpamSieve PlaySound NO")}else{system("defaults write com.c-command.SpamSieve PlaySound YES")}'

1 Like

Or a little more cleanly:

*/10 * * * * [[ $(defaults read com.apple.controlcenter "NSStatusItem Visible FocusModes") -eq 1 ]] && defaults write com.c-command.SpamSieve PlaySound NO || defaults write com.c-command.SpamSieve PlaySound YES