-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
37 lines (28 loc) · 806 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// set
const interval = 290 //in seconds
// don't change after this line
const {powerMonitor} = require('electron');
var ks = require('node-key-sender');
function getIdle(){
return powerMonitor.getSystemIdleTime();
};
function resetTime(){
ks.sendKey('shift');
}
function getTimeout() {
idle = getIdle();
//console.log('System Idle for',idle,'seconds');
if ( idle >= interval ) {
resetTime();
console.log('System Idle for',idle,'seconds. Reseting..');
timeOut = interval + 5;
}else{
//console.log('... Not enough time to reset..');
timeOut = (interval + 5 - idle);
//console.log('Will set next check to',timeOut,'seconds');
}
//console.log('Next check in',timeOut,'seconds');
setTimeout(getTimeout, timeOut*1000);
}
console.log('Started');
getTimeout();