https://github.com/131/node-screensaver
https://github.com/131/node-screensaver
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/131/node-screensaver
- Owner: 131
- License: mit
- Created: 2022-03-23T13:30:53.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-03-24T11:51:01.000Z (about 4 years ago)
- Last Synced: 2025-02-17T09:16:46.712Z (over 1 year ago)
- Language: JavaScript
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Screensaver API (for nodejs)
[](https://www.npmjs.com/package/@131/screensaver)
[](http://opensource.org/licenses/MIT)
[](https://coveralls.io/github/131/node-screensaver?branch=master)
[](https://github.com/131/ubk/actions/workflows/test.yml)
 
# Motivation
A simple screensaver API that enable you to wait for a configured idle time. And stop over user interaction.
Detecting user interaction (mostly a system wide API call, is delegated to an external closure). See below for details
# API
```
const ScreenSaver = require('@131/screensaver');
const {getIdleTime} = os.platform() == 'linux' ? require('screensaver-trigger/idle_time_linux') : require('winapi');
const timeout = 60 * 1000; //1min
const screenSaver = new ScreenSaver(timeout, getIdleTime);
screenSaver.on('open', () => {
console.log('screen saver start');
})
screenSaver.on('close', () => {
console.log('screen saver close');
})
```
# Credits
* [131](https://github.com/131)
* [idjem](https://github.com/idjem)