powerMonitor
電源の状態の変化をモニターします。
プロセス: Main
イベント
powerMonitor
モジュールでは以下のイベントが発生します。
イベント: 'suspend'
システムがサスペンドするときに発生します。
イベント: 'resume'
システムが再開するときに発生します。
イベント: 'on-ac' macOS Windows
システムが AC 電源に切り替わったときに発生します。
イベント: 'on-battery' macOS Windows
システムがバッテリー電源に切り替わったときに発生します。
Event: 'thermal-state-change' macOS
state
string - The system's new thermal state. Can beunknown
,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.
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.
イベント: 'shutdown' Linux macOS
システムが再起動またはシャットダウンしようとしているときに発生します。 イベントハンドラが e.preventDefault()
を呼び出した場合、Electron は正常にアプリを終了するためにシステムのシャットダウンの遅延を試みます。 e.preventDefault()
が呼ばれた場合、出来る限り app.quit()
のようなものを呼ぶのと同じようにアプリを終了します。
イベント: 'lock-screen' macOS Windows
システムがスクリーンをロックしようとしているときに発生します。
イベント: 'unlock-screen' macOS Windows
システムスクリーンがアンロックされたときに発行されます。
イベント: 'user-did-become-active' macOS
ログインセッションがアクティブになったときに発生します。 詳細は ドキュメント をご参照ください。
イベント: 'user-did-resign-active' macOS
ログインセッションが非アクティブになったときに発生します。 詳細は ドキュメント をご参照ください。
メソッド
powerMonitor
モジュールには以下のメソッドがあります。
powerMonitor.getSystemIdleState(idleThreshold)
idleThreshold
Integer
Returns string
- The system's current idle state. active
、 idle
、 locked
、 unknown
のいずれか。
システムのアイドル状態を計算します。 idleThreshold
は、アイドルとみなされるまでの時間 (秒) です。 locked
はサポートされたシステムでのみ利用可能です。
powerMonitor.getSystemIdleTime()
戻り値 Integer
- アイドル状態の秒数
システムのアイドル時間を計算します。
powerMonitor.getCurrentThermalState()
macOS
Returns string
- The system's current thermal state. unknown
、nominal
、fair
、serious
、critical
のいずれか。
powerMonitor.isOnBatteryPower()
戻り値 boolean
- システムがバッテリー電源状態かどうか。
このプロパティの変更を監視するには、on-battery
および on-ac
イベントを使用します。
プロパティ
powerMonitor.onBatteryPower
boolean
型のプロパティです。 システムがバッテリー電源状態ならば true です。
powerMonitor.isOnBatteryPower()
をご参照ください。