May 25, 2021 Electron
power-monitor
module is used to monitor changes in the energy zone. C
an only be used in the main process.
You
app
use
ready
module after the ready event is triggered.
For example:
app.on('ready', function() {
require('electron').powerMonitor.on('suspend', function() {
console.log('The system is going to sleep');
});
});
power-monitor
can trigger the following events:
Triggered when the system hangs.
Triggered when the system resumes to work. Emitted when system is resuming.
Triggered when the system uses AC. Emitted when the system changes to AC power.
Triggered when the system uses battery power. Emitted when system changes to battery power.