-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrenderer.js
36 lines (31 loc) · 874 Bytes
/
renderer.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
const { ipcRenderer } = require('electron');
let isBlinking = false;
let blinkInterval;
let offTimeout;
let isVisible = true;
const led = document.getElementById('led');
function startBlinking() {
if (isBlinking) return;
isBlinking = true;
led.style.display = 'block';
blinkInterval = setInterval(() => {
isVisible = !isVisible;
led.style.opacity = isVisible ? 1 : 0;
}, 500); // Adjust this value as needed
offTimeout = setTimeout(stopBlinking, 30 * 60 * 1000); // Stop after 30 minutes
}
function stopBlinking() {
isBlinking = false;
clearInterval(blinkInterval);
clearTimeout(offTimeout);
led.style.display = 'none';
}
ipcRenderer.on('toggle-led', () => {
if (isBlinking) {
stopBlinking();
} else {
startBlinking();
}
});
// Start blinking as soon as the app loads
startBlinking();