Skip to content

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.EventEmitter

Extends: NodeJS.EventEmitter

Properties

PropertyTypeDescription
onBatteryPowerbooleantrue if the system is on battery power.

Methods

MethodReturnsDescription
addListener(event, listener)thisEmitted when the system is about to lock the screen.
addListener(event, listener)thisEmitted when the system changes to AC power.
addListener(event, listener)thisEmitted when the system changes to battery power.
addListener(event, listener)thisEmitted when the system is resuming.
addListener(event, listener)thisEmitted 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)thisEmitted when the system is suspending.
addListener(event, listener)thisEmitted as soon as the system's screen is unlocked.
addListener(event, listener)thisEmitted when a login session is activated.
addListener(event, listener)thisEmitted 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()numberCalculate system idle time in seconds.
isOnBatteryPower()booleanWhether 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)thisEmitted when the system is about to lock the screen.
on('on-ac', listener)thisEmitted when the system changes to AC power.
on('on-battery', listener)thisEmitted when the system changes to battery power.
on('resume', listener)thisEmitted when the system is resuming.
on('shutdown', listener)thisEmitted 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)thisEmitted when the system is suspending.
on('unlock-screen', listener)thisEmitted as soon as the system's screen is unlocked.
on('user-did-become-active', listener)thisEmitted when a login session is activated.
on('user-did-resign-active', listener)thisEmitted when a login session is deactivated.
once(event, listener)thisAdds a one-time listener for the lock-screen event.
once(event, listener)thisAdds a one-time listener for the on-ac event.
once(event, listener)thisAdds a one-time listener for the on-battery event.
once(event, listener)thisAdds a one-time listener for the resume event.
once(event, listener)thisAdds a one-time listener for the shutdown event.
once(event, listener)thisAdds a one-time listener for the suspend event.
once(event, listener)thisAdds a one-time listener for the unlock-screen event.
once(event, listener)thisAdds a one-time listener for the user-did-become-active event.
once(event, listener)thisAdds a one-time listener for the user-did-resign-active event.
removeListener(event, listener)thisRemoves the specified listener from the lock-screen event.
removeListener(event, listener)thisRemoves the specified listener from the on-ac event.
removeListener(event, listener)thisRemoves the specified listener from the on-battery event.
removeListener(event, listener)thisRemoves the specified listener from the resume event.
removeListener(event, listener)thisRemoves the specified listener from the shutdown event.
removeListener(event, listener)thisRemoves the specified listener from the suspend event.
removeListener(event, listener)thisRemoves the specified listener from the unlock-screen event.
removeListener(event, listener)thisRemoves the specified listener from the user-did-become-active event.
removeListener(event, listener)thisRemoves the specified listener from the user-did-resign-active event.

Links to this page: