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

[Bug]: [macOS] Do not disturb triggered when focus icon in menu bar #1549

Open
5 tasks done
jsonc0 opened this issue Jan 21, 2025 · 10 comments
Open
5 tasks done

[Bug]: [macOS] Do not disturb triggered when focus icon in menu bar #1549

jsonc0 opened this issue Jan 21, 2025 · 10 comments

Comments

@jsonc0
Copy link

jsonc0 commented Jan 21, 2025

Version

  • I'm using version 1.17.2

Known issues

  • I've checked Known issues

Existing issues

  • I've checked Existing issues

Advanced Preferences

  • I've checked Advanced Preferences

What operating system are you using?

macOS

Operating System Version

Ventura 13.6.7

Reproduction steps

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

  • I agree to follow this project's Code of Conduct
@ivan-p92
Copy link

Same for me on macOS 15.2 and stretchly 1.17.2.

@hovancik
Copy link
Owner

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

@hovancik
Copy link
Owner

gpt tells me there is also defaults -currentHost read ~/Library/Preferences/ByHost/com.apple.notificationcenterui doNotDisturb can anyone try?

@ivan-p92
Copy link

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.

@jsonc0
Copy link
Author

jsonc0 commented Jan 23, 2025

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.

@ivan-p92
Copy link

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

@hovancik
Copy link
Owner

Thanks for the research! Maybe tool like this could help us identify what happens on the macos part? https://github.com/zcutlip/prefsniff

@ivan-p92
Copy link

ivan-p92 commented Jan 24, 2025

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 🥲

@hl1234
Copy link

hl1234 commented Jan 24, 2025

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

@ivan-p92
Copy link

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

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

No branches or pull requests

4 participants