Socket
Socket
Sign inDemoInstall

node-prevent-sleep

Package Overview
Dependencies
1
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node-prevent-sleep

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


Version published
Weekly downloads
9
decreased by-47.06%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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

FAQs

Last updated on 07 Jan 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc