Skip to content

Implement Do Not Disturb switching via a shortcut#82

Open
AuroraWright wants to merge 2 commits intoivoronin:mainfrom
AuroraWright:do_not_disturb
Open

Implement Do Not Disturb switching via a shortcut#82
AuroraWright wants to merge 2 commits intoivoronin:mainfrom
AuroraWright:do_not_disturb

Conversation

@AuroraWright
Copy link
Copy Markdown

@AuroraWright AuroraWright commented Aug 22, 2024

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.

jeffy-w and others added 2 commits August 23, 2024 00:21
Signed-off-by: AuroraWright <AuroraWright@users.noreply.github.com>
@yunruse
Copy link
Copy Markdown

yunruse commented Feb 28, 2025

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)

@yunruse
Copy link
Copy Markdown

yunruse commented Feb 28, 2025

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.heard

If anybody is interested, I'd be happy to add a commit second toggle & shortcut for this!

@AuroraWright
Copy link
Copy Markdown
Author

Pretty sure that violates sandboxing restrictions unfortunately
Also i think i made some changes to the code in the pr in the fork here #85 , i think this project is probably abandoned at this point

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.heard

If anybody is interested, I'd be happy to add a commit second toggle & shortcut for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants