-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
52 lines (42 loc) · 1.22 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
const { spawn, spawnSync } = require("child_process");
const { app, BrowserWindow, screen } = require("electron");
const path = require("path");
const arch = process.arch;
const serviceName =
arch === "arm64" ? "StremioService.arm.app" : "StremioService.x64.app";
const servicePath = path.join(
__dirname,
`Stremio_Runtime/${serviceName}/Contents/MacOS/stremio-service`
);
const child = spawn(servicePath, [], {
shell: true,
});
child.stdout.on("data", (data) => {
console.log(`stdout: ${data}`);
});
child.stderr.on("data", (data) => {
console.error(`stderr: ${data}`);
});
child.on("error", (err) => {
console.error(`Failed to start subprocess: ${err}`);
});
child.on("close", (code) => {
console.log(`child process exited with code ${code}`);
});
const CreateWindow = () => {
const { width, height } = screen.getPrimaryDisplay().workAreaSize;
const win = new BrowserWindow({
width: Math.round(width * 0.8),
height: Math.round(height * 0.8),
webPreferences: {
nodeIntegration: true,
},
icon: path.join(__dirname, "img/stremio.icns"),
});
win.loadURL("https://web.stremio.com");
};
app.whenReady().then(CreateWindow);
app.on("before-quit", () => {
child.kill();
spawnSync("pkill", ["-f", "stremio-runtime"]);
});