Hi @mgguinne thanks for sharing the post
You helped me a lot with this.
I use the Timing App via my Setapp subscription for time tracking and the Hey Focus app for DND mode (also web pages).
Under macOS Catalina I had these apps combined in Keyboard Maestro.
Among other things with the possibility to hide files and folders and also to mute the system sound.
To be able to work really trouble-free, I sent a notification (Pushcut App) from the Keyboard Maestro macro to my iOS devices to activate/deactivate an individual DND mode via a Siri shortcut.
Here is a video about workflow under macOS Catalina
Thanks to you, I took the AppleScript from your linked post and finally got macOS Big Sur running.
Here is my Applescript for the workflow in the video:
set output to (do shell script "defaults read com.apple.controlcenter 'NSStatusItem Visible DoNotDisturb'")
if output is "0" then
-- start focus pushcut
tell application "Keyboard Maestro Engine"
do script "DCD39657-2E6E-442C-A8A3-94696FFD62B4"
delay 0.2
end tell
open location "focus://focus" -- start focus
delay 0.2
-- start dnd
tell application "System Events" to keystroke "z" using {command down, shift down, option down, control down}
-- Hide Desktop Icon
do shell script "chflags -h hidden ~/Desktop/*"
tell application "System Events"
set volume with output muted -- mute volume
end tell
do shell script "defaults write com.apple.controlcenter 'NSStatusItem Visible DoNotDisturb' 1"
else
if output is "1" then
-- stop focus pushcut
tell application "Keyboard Maestro Engine"
do script "89440C73-D886-4C56-A598-55C88C5086E1"
end tell
-- stop dnd
tell application "System Events" to keystroke "z" using {command down, shift down, option down, control down}
-- Show Desktop Icon
do shell script "chflags -h nohidden ~/Desktop/*"
tell application "System Events"
set volume without output muted -- unmute volume
end tell
do shell script "defaults write com.apple.controlcenter 'NSStatusItem Visible DoNotDisturb' 0"
delay 0.2
open location "focus://unfocus" -- stop focus
end if
end if
What makes Pushcut very useful on iOS is the Automation Server, which allows me to have Siri perform shortcuts without picking up my iPhone.
Like in this example video for DND mode: