$ npm install @sindresorhus/do-not-disturbControl the macOS
Do Not Disturbfeature
Note that this package does not work inside a sandboxed app.
If you want to see an official API for this, please copy-paste the following into a new Feedback Assistant report, and submit it to Apple. Apple uses duplicates as an indication for how popular a request is.
npm install @sindresorhus/do-not-disturb
import doNotDisturb from '@sindresorhus/do-not-disturb';
await doNotDisturb.enable();
All the methods return a Promise. You only really need to await them if you use multiple methods at once.
.enable(): Promise<void>.disable(): Promise<void>.toggle(force?): Promise<void>Type: boolean
Force it to be enabled/disabled.
.isEnabled(): Promise<boolean>.on('change', listener, options): EventEmitterAttach an event listener that gets called when the "Do Not Disturb" state changes.
Type: object
Type: number
Default: 3000
Interval in milliseconds at which the polling for the change event is made.
.off('change', listener): EventEmitterRemove an event listener that was attached previously.
import doNotDisturb from '@sindresorhus/do-not-disturb';
const listener = status => {
console.log(`Do Not Disturb status: ${status}`);
}
doNotDisturb.on('change', listener, {pollInterval: 100});
// …
doNotDisturb.off('change', listener);