How to use the @sindresorhus/do-not-disturb.isEnabled function in @sindresorhus/do-not-disturb

To help you get started, we’ve selected a few @sindresorhus/do-not-disturb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wulkano / kap / main / common / aperture.js View on Github external
// TODO: figure out how to correctly process hevc videos with ffmpeg
  // if (recordHevc) {
  //   apertureOpts.videoCodec = 'hevc';
  // }

  console.log(`Collected settings after ${(Date.now() - past) / 1000}s`);

  if (hideDesktopIcons) {
    await desktopIcons.hide();
  }

  console.log(`Hide desktop icons after ${(Date.now() - past) / 1000}s`);

  if (doNotDisturb) {
    wasDoNotDisturbAlreadyEnabled = await dnd.isEnabled();

    if (!wasDoNotDisturbAlreadyEnabled) {
      dnd.enable();
    }
  }

  console.log(`Took care of DND after ${(Date.now() - past) / 1000}s`);

  try {
    await aperture.startRecording(apertureOpts);
  } catch (error) {
    track('recording/stopped/error');
    dialog.showErrorBox('Recording error', error.message);
    past = null;
    return;
  }
github wulkano / kap / app / src / renderer / js / main.js View on Github external
// In case for some reason the default audio device is not set
      // use the first available device for recording
      if (audioInputDeviceId) {
        apertureOpts.audioDeviceId = audioInputDeviceId;
      } else {
        const [defaultAudioDevice] = await audioDevices();
        apertureOpts.audioDeviceId = defaultAudioDevice && defaultAudioDevice.id;
      }
    }

    if (app.kap.settings.get('hideDesktopIcons')) {
      await desktopIcons.hide();
    }

    if (app.kap.settings.get('doNotDisturb')) {
      wasDoNotDisturbAlreadyEnabled = await doNotDisturb.isEnabled();

      if (!wasDoNotDisturbAlreadyEnabled) {
        doNotDisturb.enable();
      }
    }

    try {
      await aperture.startRecording(apertureOpts);
      ipcRenderer.send('did-start-recording');
      log(`Started recording after ${(Date.now() - past) / 1000}s`);
    } catch (err) {
      // This prevents the button from being reset, since the recording has not yet started
      // This delay is due to internal framework delays in aperture native code
      if (err.message.includes('stopRecording')) {
        log(`Recording not yet started, can't stop recording before it actually started`);
        return;
github sindresorhus / do-not-disturb-cli / cli.js View on Github external
(async () => {
	switch (command) {
		case 'on':
			await doNotDisturb.enable();
			break;
		case 'off':
			await doNotDisturb.disable();
			break;
		case 'toggle':
			await doNotDisturb.toggle();
			break;
		case 'status':
			console.log(await doNotDisturb.isEnabled() ? 'on' : 'off');
			break;
		default:
			cli.showHelp();
	}
})();

@sindresorhus/do-not-disturb

Control the macOS `Do Not Disturb` feature

MIT
Latest version published 3 years ago

Package Health Score

48 / 100
Full package analysis