diff --git a/CHANGELOG.md b/CHANGELOG.md index 640d9a1a..26dc22ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/app/utils/dndManager.js b/app/utils/dndManager.js index cb85fc5c..11a73fd6 100644 --- a/app/utils/dndManager.js +++ b/app/utils/dndManager.js @@ -15,7 +15,7 @@ class DndManager extends EventEmitter { 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') @@ -124,7 +124,13 @@ class DndManager extends EventEmitter { 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 + } + } catch (e) { } } else if (process.platform === 'linux') { return await this._isDndEnabledLinux() } diff --git a/package-lock.json b/package-lock.json index 2958de53..7ce1249e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,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", @@ -8115,23 +8114,6 @@ "node": ">=12" } }, - "node_modules/macos-notification-state": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/macos-notification-state/-/macos-notification-state-3.0.0.tgz", - "integrity": "sha512-tvFDZajIcwIsYg1WQAXGtrJFljlL1PEOK2cCoPDrN//XxIwTiVNvaXznxLjV4mYkyXctIDVs0ujGdrbGzeOY/w==", - "hasInstallScript": true, - "license": "MIT", - "dependencies": { - "bindings": "^1.5.0", - "node-addon-api": "3.0.0" - } - }, - "node_modules/macos-notification-state/node_modules/node-addon-api": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.0.0.tgz", - "integrity": "sha512-sSHCgWfJ+Lui/u+0msF3oyCgvdkhxDbkCS6Q8uiJquzOimkJBvX6hl5aSSA7DR1XbMpdM8r7phjcF63sF4rkKg==", - "license": "MIT" - }, "node_modules/magic-string": { "version": "0.30.17", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.17.tgz", diff --git a/package.json b/package.json index 0eb87eec..665588db 100644 --- a/package.json +++ b/package.json @@ -70,8 +70,7 @@ ], "extendInfo": { "LSBackgroundOnly": 1, - "LSUIElement": 1, - "NSFocusStatusUsageDescription": "Stretchly will respect Do Not Disturb mode" + "LSUIElement": 1 } }, "linux": { @@ -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",