aboutsummaryrefslogtreecommitdiffstats
path: root/src/electron/ipc-api/dnd.js
blob: 6fb8999a3763d80d35c12557aa1addd5bf5e7657 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { ipcMain } from 'electron';
import { getDoNotDisturb } from 'macos-notification-state';
import { isMac } from '../../environment';

const debug = require('debug')('Ferdi:ipcApi:dnd');

export default async () => {
  ipcMain.handle('get-dnd', async () => {
    if (!isMac) {
      debug('Not on macOS, returning', false);
      return false;
    }

    try {
      const isDND = getDoNotDisturb();
      debug('Fetching DND state, set to', isDND);
      return isDND;
    } catch (e) {
      console.error(e);
      return false;
    }
  });
};