Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check when the computer is idle in NodeJS?

I want to run a process in the background in NodeJS, that wait until the computer not in use for 10 minutes. I mean the user do not touch the keyboard or the mouse.

In other words: I want to listen to keyboard and mouse events in any window, and notify my app when it is happend.

For this mission, I able to use plain node, or nw.js or electron.

I think that I must to use a C++, native module and DLL's. But I hope there is a better and simple solution.

Do you have?

like image 312
Aminadav Glickshtein Avatar asked Aug 01 '16 20:08

Aminadav Glickshtein


1 Answers

You can try https://github.com/bithavoc/node-desktop-idle which works on macOS, Windows, Linux, FreeBSD and OpenBSD. I built it for Electron but it works in Node.js in general.

like image 83
bithavoc Avatar answered Sep 28 '22 02:09

bithavoc