Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/LinusU/node-dark-mode-listener
A small library for listening to dark mode changes on macOS Mojave
https://github.com/LinusU/node-dark-mode-listener
Last synced: 3 months ago
JSON representation
A small library for listening to dark mode changes on macOS Mojave
- Host: GitHub
- URL: https://github.com/LinusU/node-dark-mode-listener
- Owner: LinusU
- Created: 2018-11-21T10:54:08.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-11-18T12:42:07.000Z (almost 2 years ago)
- Last Synced: 2024-07-18T12:16:49.771Z (4 months ago)
- Language: JavaScript
- Size: 2.97 MB
- Stars: 16
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Node.js Dark Mode Listener
A small library for listening to dark mode changes on macOS Mojave.
## Installation
```sh
npm install --save dark-mode-listener
```## Usage
```js
const DarkMode = require('dark-mode-listener')DarkMode.on('change', (value) => {
console.log(`We are now in ${value} mode`)
//=> We are now in dark mode
})
```The export of the module is an `EventEmitter` that will emit a `change` event whenever dark mode is toggled on or off, and initially when the module is loaded.
## API
### event: `change`
The `change` event is emitted whenever dark mode is toggled on or off, and initially when the module is loaded. The value is a single string that will read either `'light'` or `'dark'`.
### `.currentValue`
Holds the current value, either `'light'` or `'dark'`. This property will be `undefined` until the first `change` event have been emitted.
### `.stop()`
Stop listening for changes.
## Implementation
This package ships with a small binary, [dark-mode-listener](https://github.com/LinusU/DarkModeListener), to listen to the changes.