-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
58 lines (50 loc) · 1.59 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const { app, BrowserWindow, globalShortcut, screen } = require('electron');
const useAllDisplays = true; // Set to false to use only the primary display
let windows = []; // Array to keep track of all windows
function createWindow(display) {
const { width, height, x, y } = display.bounds;
let win = new BrowserWindow({
width: 100,
height: 100,
x: x + width - 110,
y: y + height - 110,
frame: false,
transparent: true,
alwaysOnTop: true,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
}
});
windows.push(win); // Add the created window to the array
win.loadFile('index.html');
}
app.whenReady().then(() => {
if (useAllDisplays) {
const displays = screen.getAllDisplays();
displays.forEach(display => createWindow(display));
} else {
createWindow(screen.getPrimaryDisplay());
}
globalShortcut.register('Ctrl+Shift+L', () => {
windows.forEach(win => {
win.webContents.send('toggle-led');
});
});
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
if (useAllDisplays) {
const displays = screen.getAllDisplays();
displays.forEach(display => createWindow(display));
} else {
createWindow(screen.getPrimaryDisplay());
}
}
});
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit();
});
app.on('will-quit', () => {
globalShortcut.unregisterAll();
});