How to use @sindresorhus/do-not-disturb - 10 common examples

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
//   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;
  }

  const startTime = (Date.now() - past) / 1000;
  if (startTime > 3) {
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
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;
      }

      ipcRenderer.send('will-stop-recording');
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();
	}
})();
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();
	}
})();
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();
	}
})();
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();
	}
})();
github wulkano / kap / main / common / aperture.js View on Github external
const cleanup = () => {
  const {
    hideDesktopIcons,
    doNotDisturb
  } = lastUsedSettings;

  closeAllCroppers();
  resetTray();

  if (hideDesktopIcons) {
    desktopIcons.show();
  }

  if (doNotDisturb && !wasDoNotDisturbAlreadyEnabled) {
    dnd.disable();
  }

  setCropperShortcutAction();
};
github wulkano / kap / app / src / renderer / js / main.js View on Github external
const stopRecording = async () => {
    ipcRenderer.send('will-stop-recording');

    const filePath = await aperture.stopRecording();

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

    if (app.kap.settings.get('doNotDisturb') && !wasDoNotDisturbAlreadyEnabled) {
      doNotDisturb.disable();
    }

    ipcRenderer.send('stopped-recording');
    ipcRenderer.send('open-editor-window', {filePath});
    setMainWindowSize();
  };

@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