[Bug]: [macOS] Do not disturb triggered when focus icon in menu bar
Version
- [x] I'm using version 1.17.2
Known issues
- [x] I've checked Known issues
Existing issues
- [x] I've checked Existing issues
Advanced Preferences
- [x] I've checked Advanced Preferences
What operating system are you using?
macOS
Operating System Version
Ventura 13.6.7
Reproduction steps
- Set focus to "Always Show in Menu Bar" within control center
... Reproduces how often: [What percentage of the time does it reproduce?]: 100%
Expected Behavior
Stretchly should check which focus is set and only pause when dnd is set
Actual Behavior
Stretchly stays paused as long as the focus icon is visible in the menu bar as NSStatusItem Visible FocusModes returns true in this case.
Relevant log output
Preferences
Additional information
From what I can see, a recent changes was deployed where it now uses NSStatusItem Visible FocusModes to check DND mode. From what I understand, this returns true if the focus icon is shown in the menu bar. Also, the focus icon can be shown in the menu bar even when no focus mode is set.
A workaround is to check "show breaks even in Do Not Disturb" mode within preferences.
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Same for me on macOS 15.2 and stretchly 1.17.2.
I guess I will remove DND on macOS. I don't have supported macOS machine so it's kinda impossible to develop anything for macOS
gpt tells me there is also defaults -currentHost read ~/Library/Preferences/ByHost/com.apple.notificationcenterui doNotDisturb can anyone try?
There is no such preference file on my machine, and I get:
The domain/default pair of (/Users/<me>/Library/Preferences/ByHost/com.apple.notificationcenterui, doNotDisturb) does not exist
Seems like it's for older macOS versions: https://stackoverflow.com/questions/71807412/how-to-read-do-not-disturb-using-applescript
I changed my menu bar prefs to only show the DND item when it's enabled, which is an acceptable solution to me. Toggling it through the control center is just as easy, and I installed an Alfred Workflow that makes it easy to toggle it through Alfred. It creates and uses a Shortcut under the hood.
I've been able to access the focus mode by querying ~/Library/DoNotDisturb/DB/Assertions.json. It tells if no focus mode is set, if focus mode is set to do not disturb or if focus mode set to something else
Focus mode set to do not disturb
➜ cat ~/Library/DoNotDisturb/DB/Assertions.json | jq '.data[].storeAssertionRecords[].assertionDetails.assertionDetailsModeIdentifier'
"com.apple.donotdisturb.mode.default"
Focus mode set to personal
➜ cat ~/Library/DoNotDisturb/DB/Assertions.json | jq '.data[].storeAssertionRecords[].assertionDetails.assertionDetailsModeIdentifier'
"com.apple.focus.personal-time"
No focus mode set
➜ cat ~/Library/DoNotDisturb/DB/Assertions.json | jq '.data[].storeAssertionRecords[].assertionDetails.assertionDetailsModeIdentifier'
jq: error (at <stdin>:0): Cannot iterate over null (null)
You could just check whether com.apple.donotdisturb.mode.default is returned. Not sure if there is a better way and which versions of macos this would work for.
@jsonc0 Interesting. On my 15.2 machine, I get Operation not permitted on any operation in the DoNotDisturb dir, even with sudo. I can see the files in finder though. Maybe some newer restrictions have been introduced in 15.
Thanks for the research! Maybe tool like this could help us identify what happens on the macos part? https://github.com/zcutlip/prefsniff
Hi @hovancik. Interesting tool 👍
Unfortunately, it shows what we already know, that when enabling DND, or permanently showing the Focus/DND status bar item, the following pref change is applied:
defaults write com.apple.controlcenter 'NSStatusItem Visible FocusModes' -bool True
And False otherwise. Nothing more fine-grained than that 🥲
I think my experience is related so i'm not opening another issue but maybe it will give another clue. All is working fine now.
A while back I upgraded to Sequoia but I had not updated Stretchly and some other brew installed apps until just the other day. Stretchly worked fine until then. After the update it would show "Paused: Do not disturb is on". However, DND was not enabled. So I checked the Stretchly option for "Show breaks even in do not disturb mode" and Stretchly came alive.
Now if I uncheck “Show breaks even …” it now recognizes and respects DND as I enable it or disable it. Stretchly continues to work wrt DND after log out and log back in as well as restart and log in.
So it seems to be functioning properly now. It was only a problem just after my brew update. I don’t know what version I had previously.
Stretchly 1.17.2 MacOS 15.2
@hl1234 when you disable DND, do you keep the focus menu bar item in the menu bar? The problem we have is that we can't distinguish DND on from off when the focus item is always in the menu bar, due to how macOS communicates about this.
Toggling the setting on and off doesn't fix it, at least when the focus item is always shown. Also, when the focus item is configured to never show in the menu bar, stretchly can't pick up changes in DND status..
Anyway, the easiest workaround is to disable the item from always showing, which is probably fine by most people?
The workaround is fine for the time being, it's just means Stretchly is working as it did before – ignoring my Mac's DnD focus mode. I was excited to see support getting added recently, but when I realized Stretchly was also interpreting "Work" focus mode as "do not disturb", that support is not actually useful for me. The only time I want to use Stretchly is while I'm at work, and "Work" focus mode turns on automatically for me during work hours, which is important for filtering out non-work notifications. So I unfortunately had to disable Stretchly's DnD setting, and again have to keep remembering to disable Stretchly whenever I enable my Mac's actual DnD focus mode.
Thanks however for continuing to look into a fix for this issue, much appreciated. I assume BrowserStack doesn't let you test actual apps on macOS devices, just websites? Frustrating not being able to develop macOS apps without owning the hardware…
So when you have Work mode, do you get notifications from other apps? I don't understand how Focus mode works, but the goal of DND feature in Stretchly is "If user set OS not to send notifications, do not send breaks."
"Focus" modes are customizable in macOS/iOS in terms of which apps and/or people are allowed to generate notifications. In my "Work" focus mode, I've set up exceptions for which applications I want to be allowed to produce notifications; the remaining applications are ignored. Here are some screenshots of its settings to help illustrate:
I see, so we need a way to get information "Is Stretchly allowed to send notifications in current Focus mode?". Googling around but don't see a way
Yes it sounds more non-trivial than expected. Essentially trying to determine if notifications are currently "muted" for a specific app, not whether permission to generate notifications has been granted.