electron-util
Version:
Useful utilities for Electron apps and modules
29 lines (25 loc) • 690 B
TypeScript
export type DarkMode = {
/**
Whether the macOS dark mode is enabled.
On Windows and Linux, it's `false`.
*/
readonly isEnabled: boolean;
/**
The `callback` function is called when the macOS dark mode is toggled.
@returns A function, that when called, unsubscribes the listener. Calling it on Window and Linux works, but it just returns a no-op function.
*/
readonly onChange: (callback: () => void) => () => void;
};
/**
@example
```
import {darkMode} from 'electron-util';
console.log(darkMode.isEnabled);
//=> false
darkMode.onChange(() => {
console.log(darkMode.isEnabled);
//=> true
});
```
*/
export declare const darkMode: DarkMode;