Implement Do Not Disturb switching via a shortcut#82
Implement Do Not Disturb switching via a shortcut#82AuroraWright wants to merge 2 commits intoivoronin:mainfrom
Conversation
Signed-off-by: AuroraWright <AuroraWright@users.noreply.github.com>
|
Works beautifully on my system. Good to merge. It seems a bit unconventional, but macOS sadly has no ways to toggle DnD natively from Swift – this is the best method. Using a shortcut is actually quite smart, because you can modify it (to change what Focus mode it toggles, add a custom sound, etc etc) |
|
On the topic of hooking into that shortcut: turns out you can get it to set Background Sounds. In the respective branches of macos-focus-mode, use Run Shell Script with: defaults write com.apple.ComfortSounds comfortSoundsEnabled -bool {true,false}
killall heard
launchctl kickstart gui/$(id -u)/com.apple.accessibility.heardIf anybody is interested, I'd be happy to add a commit second toggle & shortcut for this! |
|
Pretty sure that violates sandboxing restrictions unfortunately
|
This implements #30 . The shortcut is taken from https://github.com/arodik/macos-focus-mode which is under MIT as well, as far as I can tell. I also included the auto-resize commit from #65 to make the popover UI work fine.
If DND toggling is enabled, the user is prompted by Shortcuts.app to install the shortcut the first time the timer is run, and it works normally afterwards. DND.swift is basically taken almost verbatim from the Apple WWDC 21 Shortcuts examples, I've never worked with Swift before so feel free to double check.