Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Do Not Disturb switching via a shortcut #82

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

AuroraWright
Copy link

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

@yunruse
Copy link

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

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