Saltar al contenido principal

powerMonitor

Monitorea los cambios de estado de energía.

Proceso: principal</0>

Eventos

El módulo powerMonitor emite los siguientes eventos:

Evento: "suspend"

Se emite cuando se suspende el sistema.

Evento: "resume"

Se emite cuando se reanuda el sistema.

Event: 'on-ac' macOS Windows

Se emite cuando el sistema se cambia a la corriente alterna.

Event: 'on-battery' macOS Windows

Se emite cuando el sistema se cambia a la energía de batería.

Event: 'thermal-state-change' macOS

  • state string - The system's new thermal state. Can be unknown, nominal, fair, serious, critical.

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.

Apps may react to the new state by reducing expensive computing tasks (e.g. video encoding), or notifying the user. The same state might be received repeatedly.

See https://developer.apple.com/library/archive/documentation/Performance/Conceptual/power_efficiency_guidelines_osx/RespondToThermalStateChanges.html

Event: 'speed-limit-change' macOS Windows

  • limit number - The operating system's advertised speed limit for CPUs, in percent.

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.

Evento: 'shutdown' Linux macOS

Se emite cuando el sistema está a punto de reiniciarse o apagarse. Si el controlador de eventos invocó e.preventDefault(), Electron intentará retrasar el apagado del sistema para que la aplicación salga limpiamente. Si se llama a e.preventDefault(), la aplicación debe salir tan pronto como sea posible llamando a algo como app.quit().

Evento: 'lock-screen' macOS Windows

Emitido cuando el sistema está a punto de bloquear la pantalla.

Evento: 'unlock-screen' macOS Windows

Emitido tan pronto como el sistema desbloquea la pantalla.

Evento: 'user-did-become-active' macOS

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

Evento: 'user-did-resign-active' macOS

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

Métodos

El modulo powerMonitor tiene los siguientes métodos:

powerMonitor.getSystemIdleState(idleThreshold)

  • idleThreshold Integer

Returns string - The system's current idle state. Puede ser active, idle, locked o unknown.

Calcule el estado de reposo del sistema. idleThreshold es la cantidad de tiempo (en segundos) antes de considerar inactivo. locked is available on supported systems only.

powerMonitor.getSystemIdleTime()

Devuelve Integer - Tiempo inactivo en segundos

Calcular tiempo inactivo del sistema en segundos.

powerMonitor.getCurrentThermalState() macOS

Returns string - The system's current thermal state. Puede ser unknown, nominal, fair, serious, o critical.

powerMonitor.isOnBatteryPower()

Returns boolean - Whether the system is on battery power.

To monitor for changes in this property, use the on-battery and on-ac events.

Propiedades

powerMonitor.onBatteryPower

Una propiedad boolean. True if the system is on battery power.

Echa un vistazo a powerMonitor.isOnBatteryPower().