node-prevent-sleep
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

node-prevent-sleep

Allows to prevent the system from turning off the display, or suspending the computer.

Usage

const preventSleep = require("node-prevent-sleep");
// import preventSleep from 'node-prevent-sleep';

// Disables sleep
preventSleep.enable();

// Enables sleep
preventSleep.disable();

How it works

Windows

When enable() is used, power request is created using PowerCreateRequest and set using PowerSetRequest with flags PowerRequestSystemRequired and PowerRequestDisplayRequired, which prevents system sleeping.

When disable() is used, power request is cleared using PowerClearRequest, restoring previous behavior.

Linux

Not supported yet. You are welcome to submit a PR with the functionality.

Mac

Not supported yet. You are welcome to submit a PR with the functionality.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i node-prevent-sleep

Weekly Downloads

19

Version

0.0.4

License

MIT

Unpacked Size

6.21 kB

Total Files

10

Last publish

Collaborators

  • sebastian.alex