https://github.com/theunderscorer/do-not-disturb
A simple utility functions for managing "Do Not Disturb" feature. Currently supports only MacOS.
https://github.com/theunderscorer/do-not-disturb
api dnd do-not-disturb nodejs package typescript
Last synced: 3 months ago
JSON representation
A simple utility functions for managing "Do Not Disturb" feature. Currently supports only MacOS.
- Host: GitHub
- URL: https://github.com/theunderscorer/do-not-disturb
- Owner: TheUnderScorer
- License: mit
- Created: 2021-06-06T11:24:11.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-07-16T16:01:00.000Z (almost 2 years ago)
- Last Synced: 2025-02-17T06:17:19.964Z (4 months ago)
- Topics: api, dnd, do-not-disturb, nodejs, package, typescript
- Language: TypeScript
- Homepage:
- Size: 188 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Do Not Disturb
[](https://www.npmjs.com/package/@theunderscorer/do-not-disturb)
[](https://www.npmjs.com/package/@theunderscorer/do-not-disturb)A simple API for managing "Do Not Disturb" mode.
> Currently only MacOS is supported.
## Installation
```sh
$ npm install @theunderscorer/do-not-disturb
```## Why this exists
There are already plenty of packages for managing "Do Not Disturb" mode, however I was not able to get them to work on
latest MacOS version (Big Sur) hence I've created this package :P.For MacOS Montrey it uses a combo of `macos-focus-mode` for toggling DnD mode, and `macos-notification-state` for checking if DnD mode is enabled or not.
It also supports older MacOS versions via `@sindresorhus/do-not-disturb` package used as fallback.
## Usage
```js
import {
enable,
disable,
toggle,
isEnabled,
installRequired,
install
} from '@theunderscorer/do-not-disturb';// Enables "Do Not Disturb" mode
await enable();// Disables "Do Not Disturb" mode
await disable();// Toggles "Do Not Disturb" mode
await toggle();// Returns "true" if "Do Not Disturb" mode is enabled
await isEnabled();// Returns "true" if driver needs to be installed (which is a case for MacOS Montrey)
await installRequired();// Installs DnD driver if it is required. If not, does nothing.
await install();
```## Development
The package is written in typescript. In order to build it run:
```sh
$ npm run build
```To run tests (will run only on MacOS) run:
```sh
$ npm run test
```## Future plans
- [ ] Support Linux and Windows
- [ ] Test Suite for CI