Skip to content

Commit 343913e

Browse files
authored
Merge pull request #1540 from hovancik/fix/dnd-mac
Improve macOS DND detection
2 parents 5e44b41 + 79ab66e commit 343913e

File tree

4 files changed

+10
-23
lines changed

4 files changed

+10
-23
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77
## [Unreleased]
88
### Fixed
99
- Linux DND detection
10+
- improve macOS DND detection
1011
- debug info when from Windows Store
1112

1213
## [1.17.1] - 2024-12-25

app/utils/dndManager.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class DndManager extends EventEmitter {
1515
this.windowsFocusAssist = require('windows-focus-assist')
1616
this.windowsQuietHours = require('windows-quiet-hours')
1717
} else if (process.platform === 'darwin') {
18-
this.macosNotificationState = require('macos-notification-state')
18+
this.util = require('node:util')
1919
} else if (process.platform === 'linux') {
2020
this.bus = require('dbus-final').sessionBus()
2121
this.util = require('node:util')
@@ -124,7 +124,13 @@ class DndManager extends EventEmitter {
124124
const wqh = this.windowsQuietHours.getIsQuietHours()
125125
return wqh || (wfa !== -1 && wfa !== 0)
126126
} else if (process.platform === 'darwin') {
127-
return this.macosNotificationState.getDoNotDisturb()
127+
try {
128+
const exec = this.util.promisify(require('node:child_process').exec)
129+
const { stdout } = await exec('defaults read com.apple.controlcenter "NSStatusItem Visible FocusModes"')
130+
if (stdout.replace(/[^0-9a-zA-Z]/g, '') === '1') {
131+
return true
132+
}
133+
} catch (e) { }
128134
} else if (process.platform === 'linux') {
129135
return await this._isDndEnabledLinux()
130136
}

package-lock.json

Lines changed: 0 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@
7070
],
7171
"extendInfo": {
7272
"LSBackgroundOnly": 1,
73-
"LSUIElement": 1,
74-
"NSFocusStatusUsageDescription": "Stretchly will respect Do Not Disturb mode"
73+
"LSUIElement": 1
7574
}
7675
},
7776
"linux": {
@@ -157,7 +156,6 @@
157156
"i18next": "^23.16.8",
158157
"i18next-fs-backend": "^2.6.0",
159158
"luxon": "^3.5.0",
160-
"macos-notification-state": "^3.0.0",
161159
"meeussunmoon": "^3.0.3",
162160
"ps-list": "7.2",
163161
"rtl-detect": "^1.1.2",

0 commit comments

Comments
 (0)