-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
96 lines (84 loc) · 2.39 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
const { app, BrowserWindow } = require('electron')
const { ipcMain } = require('electron')
const { exec } = require('child_process');
// let process = null
function createWindow() {
const win = new BrowserWindow({
width: 600,
height: 200,
webPreferences: {
nodeIntegration: true
}
})
win.loadFile('index.html')
}
app.whenReady().then(createWindow)
app.on('window-all-closed', () => {
// if (process.platform !== 'darwin') {
app.quit()
// }
})
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})
// runtime
ipcMain.on('pulse-led', (event, val) => {
console.log('Pulse...', val)
exec('g413-led -fx breathing all ff0000 ' + val, (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.error(`stderr: ${stderr}`);
});
})
ipcMain.on('on-led', (event) => {
console.log('Off...')
exec('g413-led -a ff0000', (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.error(`stderr: ${stderr}`);
});
})
ipcMain.on('off-led', (event) => {
console.log('Off...')
exec('g413-led -a 000000', (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.error(`stderr: ${stderr}`);
});
})
ipcMain.on('change-led', (event, val) => {
console.log('Change...', val)
exec('g413-led -a ' + val + '0000', (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.error(`stderr: ${stderr}`);
});
})
ipcMain.on('hook-notifications', (event) => {
console.log('Hooking...')
process = exec('python3 ./hook-notifications.py', (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.error(`stderr: ${stderr}`);
});
})
ipcMain.on('unhook-notifications', (event) => {
console.log('Unhooking...', process.kill());
})