Skip to content

Commit cb91b17

Browse files
committed
enable dnd check for macOS Montery
1 parent 6b61418 commit cb91b17

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"i": "0.3.6",
6060
"jsonwebtoken": "8.5.1",
6161
"lodash": "^4.17.4",
62+
"macos-notification-state": "git://github.com/nbashkankov/macos-notification-state.git#c7959ecf657020a70b2720d1051fc5a3e4ecb118",
6263
"macos-version": "5.2.0",
6364
"marked": "0.6.1",
6465
"mdi": "^1.9.33",

src/electron/ipc-api/dnd.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { ipcMain } from 'electron';
2-
import { execSync } from 'child_process';
32
import { isMac } from '../../environment';
43

54
const debug = require('debug')('Franz:ipcApi:dnd');
@@ -13,8 +12,12 @@ export default async () => {
1312
}
1413

1514
try {
16-
const dndQueryResponse = execSync('defaults read com.apple.controlcenter "NSStatusItem Visible DoNotDisturb"');
17-
const isDND = Buffer.from(dndQueryResponse).toString().trim() === '1';
15+
// eslint-disable-next-line global-require
16+
const { getNotificationState } = require('macos-notification-state');
17+
18+
const state = getNotificationState();
19+
20+
const isDND = state === 'DO_NOT_DISTURB';
1821

1922
debug('Fetching DND state, set to', isDND);
2023
return isDND;

0 commit comments

Comments
 (0)