Swiftpack.co - sindresorhus/do-not-disturb as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by sindresorhus.
sindresorhus/do-not-disturb v2.0.0
Control the macOS `Do Not Disturb` feature
⭐️ 185
🕓 7 weeks ago
macOS
.package(url: "https://github.com/sindresorhus/do-not-disturb.git", from: "v2.0.0")

do-not-disturb

Control the macOS Do Not Disturb feature

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.

Install

npm install @sindresorhus/do-not-disturb

Usage

import doNotDisturb from '@sindresorhus/do-not-disturb';

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.

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);

Related

GitHub

link
Stars: 185
Last commit: 7 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

7 weeks ago

Breaking

  • Require Node.js 12.20 1693472
  • This package is now pure ESM. Please read this.

https://github.com/sindresorhus/do-not-disturb/compare/v1.1.0...v2.0.0

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics