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

Improve macOS DND detection #1540

Merged
merged 1 commit into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
### Fixed
- Linux DND detection
- improve macOS DND detection
- debug info when from Windows Store

## [1.17.1] - 2024-12-25
Expand Down
10 changes: 8 additions & 2 deletions app/utils/dndManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
this.windowsFocusAssist = require('windows-focus-assist')
this.windowsQuietHours = require('windows-quiet-hours')
} else if (process.platform === 'darwin') {
this.macosNotificationState = require('macos-notification-state')
this.util = require('node:util')
} else if (process.platform === 'linux') {
this.bus = require('dbus-final').sessionBus()
this.util = require('node:util')
Expand Down Expand Up @@ -124,7 +124,13 @@
const wqh = this.windowsQuietHours.getIsQuietHours()
return wqh || (wfa !== -1 && wfa !== 0)
} else if (process.platform === 'darwin') {
return this.macosNotificationState.getDoNotDisturb()
try {
const exec = this.util.promisify(require('node:child_process').exec)
const { stdout } = await exec('defaults read com.apple.controlcenter "NSStatusItem Visible FocusModes"')
if (stdout.replace(/[^0-9a-zA-Z]/g, '') === '1') {
return true

Check warning on line 131 in app/utils/dndManager.js

View check run for this annotation

Codecov / codecov/patch

app/utils/dndManager.js#L127-L131

Added lines #L127 - L131 were not covered by tests
}
} catch (e) { }
} else if (process.platform === 'linux') {
return await this._isDndEnabledLinux()
}
Expand Down
18 changes: 0 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@
],
"extendInfo": {
"LSBackgroundOnly": 1,
"LSUIElement": 1,
"NSFocusStatusUsageDescription": "Stretchly will respect Do Not Disturb mode"
"LSUIElement": 1
}
},
"linux": {
Expand Down Expand Up @@ -157,7 +156,6 @@
"i18next": "^23.16.8",
"i18next-fs-backend": "^2.6.0",
"luxon": "^3.5.0",
"macos-notification-state": "^3.0.0",
"meeussunmoon": "^3.0.3",
"ps-list": "7.2",
"rtl-detect": "^1.1.2",
Expand Down
Loading