Skip to content

perf2711/node-prevent-sleep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published