Skip to content

Commit

Permalink
enable dnd check for macOS Montery
Browse files Browse the repository at this point in the history
  • Loading branch information
adlk committed Nov 15, 2021
1 parent 6b61418 commit cb91b17
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"i": "0.3.6",
"jsonwebtoken": "8.5.1",
"lodash": "^4.17.4",
"macos-notification-state": "git://github.com/nbashkankov/macos-notification-state.git#c7959ecf657020a70b2720d1051fc5a3e4ecb118",
"macos-version": "5.2.0",
"marked": "0.6.1",
"mdi": "^1.9.33",
Expand Down
9 changes: 6 additions & 3 deletions src/electron/ipc-api/dnd.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ipcMain } from 'electron';
import { execSync } from 'child_process';
import { isMac } from '../../environment';

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

try {
const dndQueryResponse = execSync('defaults read com.apple.controlcenter "NSStatusItem Visible DoNotDisturb"');
const isDND = Buffer.from(dndQueryResponse).toString().trim() === '1';
// eslint-disable-next-line global-require
const { getNotificationState } = require('macos-notification-state');

const state = getNotificationState();

const isDND = state === 'DO_NOT_DISTURB';

debug('Fetching DND state, set to', isDND);
return isDND;
Expand Down

0 comments on commit cb91b17

Please sign in to comment.