PowerMonitor

external interface PowerMonitor : EventEmitter(source)

Properties

Link copied to clipboard
abstract var onBatteryPower: Boolean

A boolean property. True if the system is on battery power.

Functions

Link copied to clipboard
abstract fun addListener(event: PowerMonitorEvent.LOCK_SCREEN, listener: Function<Unit>)
abstract fun addListener(event: PowerMonitorEvent.ON_AC, listener: Function<Unit>)
abstract fun addListener(event: PowerMonitorEvent.ON_BATTERY, listener: Function<Unit>)
abstract fun addListener(event: PowerMonitorEvent.RESUME, listener: Function<Unit>)
abstract fun addListener(event: PowerMonitorEvent.SHUTDOWN, listener: Function<Unit>)
abstract fun addListener(event: PowerMonitorEvent.SUSPEND, listener: Function<Unit>)
abstract fun addListener(event: PowerMonitorEvent.UNLOCK_SCREEN, listener: Function<Unit>)
Link copied to clipboard
Link copied to clipboard

The system's current thermal state. Can be unknown, nominal, fair, serious, or critical.

Link copied to clipboard
Link copied to clipboard

The system's current idle state. Can be active, idle, locked or unknown.

Link copied to clipboard
abstract fun getSystemIdleTime(): Double

Idle time in seconds

Link copied to clipboard
abstract fun isOnBatteryPower(): Boolean

Whether the system is on battery power.

Link copied to clipboard
abstract fun off(event: PowerMonitorEvent.LOCK_SCREEN, listener: Function<Unit>)
abstract fun off(event: PowerMonitorEvent.ON_AC, listener: Function<Unit>)
abstract fun off(event: PowerMonitorEvent.ON_BATTERY, listener: Function<Unit>)
abstract fun off(event: PowerMonitorEvent.RESUME, listener: Function<Unit>)
abstract fun off(event: PowerMonitorEvent.SHUTDOWN, listener: Function<Unit>)
abstract fun off(event: PowerMonitorEvent.SPEED_LIMIT_CHANGE, listener: Function<Unit>)
abstract fun off(event: PowerMonitorEvent.SUSPEND, listener: Function<Unit>)
abstract fun off(event: PowerMonitorEvent.THERMAL_STATE_CHANGE, listener: Function<Unit>)
abstract fun off(event: PowerMonitorEvent.UNLOCK_SCREEN, listener: Function<Unit>)
Link copied to clipboard
abstract fun on(event: PowerMonitorEvent.LOCK_SCREEN, listener: Function<Unit>)

Emitted when the system is about to lock the screen.

abstract fun on(event: PowerMonitorEvent.ON_AC, listener: Function<Unit>)

Emitted when the system changes to AC power.

abstract fun on(event: PowerMonitorEvent.ON_BATTERY, listener: Function<Unit>)

Emitted when system changes to battery power.

abstract fun on(event: PowerMonitorEvent.RESUME, listener: Function<Unit>)

Emitted when system is resuming.

abstract fun on(event: PowerMonitorEvent.SHUTDOWN, listener: Function<Unit>)

Emitted when the system is about to reboot or shut down. If the event handler invokes e.preventDefault(), Electron will attempt to delay system shutdown in order for the app to exit cleanly. If e.preventDefault() is called, the app should exit as soon as possible by calling something like app.quit().

abstract fun on(event: PowerMonitorEvent.SPEED_LIMIT_CHANGE, listener: Function<Unit>)

Notification of a change in the operating system's advertised speed limit for CPUs, in percent. Values below 100 indicate that the system is impairing processing power due to thermal management.

abstract fun on(event: PowerMonitorEvent.SUSPEND, listener: Function<Unit>)

Emitted when the system is suspending.

abstract fun on(event: PowerMonitorEvent.THERMAL_STATE_CHANGE, listener: Function<Unit>)

Emitted when the thermal state of the system changes. Notification of a change in the thermal status of the system, such as entering a critical temperature range. Depending on the severity, the system might take steps to reduce said temperature, for example, throttling the CPU or switching on the fans if available.

abstract fun on(event: PowerMonitorEvent.UNLOCK_SCREEN, listener: Function<Unit>)

Emitted as soon as the systems screen is unlocked.

abstract fun on(event: PowerMonitorEvent.USER_DID_BECOME_ACTIVE, listener: Function<Unit>)

Emitted when a login session is activated. See documentation for more information.

abstract fun on(event: PowerMonitorEvent.USER_DID_RESIGN_ACTIVE, listener: Function<Unit>)

Emitted when a login session is deactivated. See documentation for more information.

Link copied to clipboard
abstract fun once(event: PowerMonitorEvent.LOCK_SCREEN, listener: Function<Unit>)
abstract fun once(event: PowerMonitorEvent.ON_AC, listener: Function<Unit>)
abstract fun once(event: PowerMonitorEvent.ON_BATTERY, listener: Function<Unit>)
abstract fun once(event: PowerMonitorEvent.RESUME, listener: Function<Unit>)
abstract fun once(event: PowerMonitorEvent.SHUTDOWN, listener: Function<Unit>)
abstract fun once(event: PowerMonitorEvent.SPEED_LIMIT_CHANGE, listener: Function<Unit>)
abstract fun once(event: PowerMonitorEvent.SUSPEND, listener: Function<Unit>)
abstract fun once(event: PowerMonitorEvent.THERMAL_STATE_CHANGE, listener: Function<Unit>)
abstract fun once(event: PowerMonitorEvent.UNLOCK_SCREEN, listener: Function<Unit>)
Link copied to clipboard