electron/docs/api/power-monitor.md

34 lines
661 B
Markdown
Raw Normal View History

2013-09-09 07:35:57 +00:00
# power-monitor
2013-08-14 22:43:35 +00:00
The `power-monitor` module is used to monitor the power state change. You can
only use it on the main process. You should not use this module until the `ready`
event of `app` module gets emitted.
2013-08-14 22:43:35 +00:00
An example is:
```javascript
var app = require('app');
app.on('ready', function() {
2015-04-15 15:17:10 +00:00
require('power-monitor').on('suspend', function() {
console.log('The system is going to sleep');
});
2013-08-14 22:43:35 +00:00
});
```
## Event: suspend
Emitted when the system is suspending.
## Event: resume
Emitted when system is resuming.
## Event: on-ac
Emitted when the system changes to AC power.
## Event: on-battery
Emitted when system changes to battery power.