ElectronPowerMonitor
Unofficial
Electron powerMonitor module for monitoring power state changes.
Import:
import type { ElectronPowerMonitor } from '@obsidian-typings/obsidian-public-latest';Signature:
export interface ElectronPowerMonitor extends NodeJS.EventEmitterExtends: NodeJS.EventEmitter
Properties
| Property | Type | Description | |
|---|---|---|---|
| onBatteryPower | boolean | true if the system is on battery power. |
Methods
| Method | Returns | Description | |
|---|---|---|---|
| addListener(event, listener) | this | Emitted when the system is about to lock the screen. | |
| addListener(event, listener) | this | Emitted when the system changes to AC power. | |
| addListener(event, listener) | this | Emitted when the system changes to battery power. | |
| addListener(event, listener) | this | Emitted when the system is resuming. | |
| addListener(event, listener) | this | Emitted when the system is about to reboot or shut down. If the event handler invokes event.preventDefault(), Electron will attempt to delay system shutdown in order for the app to exit cleanly. | |
| addListener(event, listener) | this | Emitted when the system is suspending. | |
| addListener(event, listener) | this | Emitted as soon as the system's screen is unlocked. | |
| addListener(event, listener) | this | Emitted when a login session is activated. | |
| addListener(event, listener) | this | Emitted when a login session is deactivated. | |
| getSystemIdleState(idleThreshold) | 'active' | 'idle' | 'locked' | 'unknown' | Calculate the system idle state. idleThreshold is the amount of time (in seconds) before considered idle. locked is available on supported systems only. | |
| getSystemIdleTime() | number | Calculate system idle time in seconds. | |
| isOnBatteryPower() | boolean | Whether the system is on battery power. To monitor for changes in this property, use the on-battery and on-ac events. | |
| on('lock-screen', listener) | this | Emitted when the system is about to lock the screen. | |
| on('on-ac', listener) | this | Emitted when the system changes to AC power. | |
| on('on-battery', listener) | this | Emitted when the system changes to battery power. | |
| on('resume', listener) | this | Emitted when the system is resuming. | |
| on('shutdown', listener) | this | Emitted when the system is about to reboot or shut down. If the event handler invokes event.preventDefault(), Electron will attempt to delay system shutdown in order for the app to exit cleanly. | |
| on('suspend', listener) | this | Emitted when the system is suspending. | |
| on('unlock-screen', listener) | this | Emitted as soon as the system's screen is unlocked. | |
| on('user-did-become-active', listener) | this | Emitted when a login session is activated. | |
| on('user-did-resign-active', listener) | this | Emitted when a login session is deactivated. | |
| once(event, listener) | this | Adds a one-time listener for the lock-screen event. | |
| once(event, listener) | this | Adds a one-time listener for the on-ac event. | |
| once(event, listener) | this | Adds a one-time listener for the on-battery event. | |
| once(event, listener) | this | Adds a one-time listener for the resume event. | |
| once(event, listener) | this | Adds a one-time listener for the shutdown event. | |
| once(event, listener) | this | Adds a one-time listener for the suspend event. | |
| once(event, listener) | this | Adds a one-time listener for the unlock-screen event. | |
| once(event, listener) | this | Adds a one-time listener for the user-did-become-active event. | |
| once(event, listener) | this | Adds a one-time listener for the user-did-resign-active event. | |
| removeListener(event, listener) | this | Removes the specified listener from the lock-screen event. | |
| removeListener(event, listener) | this | Removes the specified listener from the on-ac event. | |
| removeListener(event, listener) | this | Removes the specified listener from the on-battery event. | |
| removeListener(event, listener) | this | Removes the specified listener from the resume event. | |
| removeListener(event, listener) | this | Removes the specified listener from the shutdown event. | |
| removeListener(event, listener) | this | Removes the specified listener from the suspend event. | |
| removeListener(event, listener) | this | Removes the specified listener from the unlock-screen event. | |
| removeListener(event, listener) | this | Removes the specified listener from the user-did-become-active event. | |
| removeListener(event, listener) | this | Removes the specified listener from the user-did-resign-active event. |
Links to this page: