Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

@sindresorhus/do-not-disturb

1.1.0 • Public • Published

do-not-disturb Build Status

Control the macOS Do Not Disturb feature

Note that this package does not work inside a sandboxed app.

Install

$ npm install @sindresorhus/do-not-disturb

Usage

const doNotDisturb = require('@sindresorhus/do-not-disturb');
 
(async () => {
    await doNotDisturb.enable();
})();

API

doNotDisturb

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>

force

Type: boolean

Force it to be enabled/disabled.

.isEnabled(): Promise<boolean>

.on('change', listener, options): EventEmitter

Attach an event listener that gets called when the "Do Not Disturb" state changes.

options

Type: object

pollInterval

Type: number
Default: 3000

Interval in milliseconds at which the polling for the change event is made.

.off('change', listener): EventEmitter

Remove an event listener that was attached previously.

const doNotDisturb = require('@sindresorhus/do-not-disturb');
 
const listener = status => {
    console.log(`Do Not Disturb status: ${status}`);
}
 
doNotDisturb.on('change', listener, {pollInterval: 100});
 
// …
doNotDisturb.off('change', listener);

Related

Install

npm i @sindresorhus/do-not-disturb

DownloadsWeekly Downloads

1,852

Version

1.1.0

License

MIT

Unpacked Size

10 MB

Total Files

5

Last publish

Collaborators

  • avatar