0.1.2 • Published 6 years ago
dark-mode-listener v0.1.2
Node.js Dark Mode Listener
A small library for listening to dark mode changes on macOS Mojave.
Installation
npm install --save dark-mode-listenerUsage
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.