Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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: about 2 months ago
JSON representation

A small library for listening to dark mode changes on macOS Mojave

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.