Hi everyone, I am trying to write an AppleScript script in Nodejs that can interact with the system’s Do Not Disturb Mode. Please how do I write this?
Charles. I’m not familiar with NodeJS and can’t help there.
FWIW, one solution is to call a shortcut from an AppleScript, although this requires a recent version of macOS. A simple AppleScript example:
set doNotDisturbStatus to "Turn Off" --either "Turn On" or "Turn Off"
if doNotDisturbStatus is "Turn On" then
tell application "Shortcuts Events" to run shortcut named "Do Not Disturb" with input doNotDisturbStatus
else
tell application "Shortcuts Events" to run shortcut named "Do Not Disturb" with input doNotDisturbStatus
end if
The shortcut:
Do Not Disturb.shortcut (22.1 KB)