All Projects → LinusU → node-dark-mode-listener

LinusU / node-dark-mode-listener

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

Programming Languages

javascript
184084 projects - #8 most used programming language
VBScript
123 projects

Node.js Dark Mode Listener

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

Installation

npm install --save dark-mode-listener

Usage

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, to listen to the changes.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].