vitorgalvao/tiny-scripts

calm-notifications does not seem to work with macOS Monterey

tjluoma opened this issue · 8 comments

DND is now "Focus Modes" and calm-notifications does not seem to 'grok' those yet. This isn't surprising, given that it's a whole new system, but just something I wanted to flag so others would be aware.

calm-notifications status always results in on for me.

macOS version 12.0.1 (21A559)

Thank you for the report. I feared as much. Despite having a Mac with a dedicated DND key, I do intend to try to fix this because I use it in automated contexts and it’s what powers the Alfred Workflow.

I’m not yet on Monterey so it will have to wait until then. But unlike previous years I don’t intend to wait months to do it. I just have to first figure out my (in progress) plan to ditch Dropbox.

calm-notifications status always results in on for me.

But does it turn it off and on accurately?

But does it turn it off and on accurately?

No. It does not toggle, turn on or off, or check the status correctly. It does not seem to do anything, unfortunately.

FWIW - Monterey has been terrific for me. As stable as Big Sur and Catalina were after several "point 1" updates.

With Shortcuts on Monterey, one should be able to use its CLI tool to turn DND on and off. That probably won’t allow checking the state, but this was very hard to get working in the first place.

I recommend going the shortcuts CLI route and will deprecate the script. I’ll reconsider if someone finds a solution on Monterey, but I already spent too much of my free time on things that Apple breaks.

https://gist.github.com/drewkerr/0f2b61ce34e2b9e3ce0ec6a92ab05c18 gives a way to find out which focus mode is enabled. I made Shortcuts to turn DND on and off, and then wrote a script which checks the 'mode' currently enabled, and runs the appropriate shortcut.

Which isn't as nice and neat as this self-contained script was, but it works OK for me.

If these can really be read from JSON files, I may take another look. Though I don’t imagine I’ll add support for all Focus Modes; I’d probably stick to all or nothing.

I can vouch that the technique in the gist works perfectly, and fast.

I simply check for the focus mode named "Do Not Disturb".

I suppose you could check for 'a focus mode is currently on or not' too.

That gist doesn’t work for me. Either way, the code is overly long and complex. This can be achieved in a single line:

defaults read com.apple.controlcenter "NSStatusItem Visible FocusModes"

Returns 0 if off, 1 if on.

This script’s goal was always to support the Alfred Workflow. I updated the Workflow to do it via a macOS Shortcut. You can install it and use it from the command-line as well:

shortcuts run 'Calm Notifications' <<< 'on'
shortcuts run 'Calm Notifications' <<< 'off'