diff options
author | 0neGal <mail@0negal.com> | 2024-02-04 15:40:23 +0100 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2024-02-04 15:46:55 +0100 |
commit | e8e502cc574fdd6eaa54a3a25c2d975596c13026 (patch) | |
tree | d193b02d9f37afe109a497b99b6bffc54a5cab64 /src/modules/kill.js | |
parent | ceda605611c9ec2fbe858f3ae29942d56a06ac66 (diff) | |
download | Viper-e8e502cc574fdd6eaa54a3a25c2d975596c13026.tar.gz Viper-e8e502cc574fdd6eaa54a3a25c2d975596c13026.zip |
move IPC events into their respective modules
I've not been able to find anything that breaks from this, as I've gone
through every IPC event that got moved, to ensure it still functions,
and all the breakage I found has since been fixed.
IPC events that dont fit in any particular module is also now in the new
file named `src/app/modules/ipc.js`
There's also another module `src/win.js`, which lets you get the
`BrowserWindow` outside of `src/index.js`
I also took the oppertunity to clean up some of the code when moving it
around, and adding a couple comments, as some of it was quite horrid.
Diffstat (limited to 'src/modules/kill.js')
-rw-r--r-- | src/modules/kill.js | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/modules/kill.js b/src/modules/kill.js index 3c93f7b..43eda23 100644 --- a/src/modules/kill.js +++ b/src/modules/kill.js @@ -1,4 +1,13 @@ const exec = require("child_process").exec; +const ipcMain = require("electron").ipcMain; + +ipcMain.on("kill-game", () => { + kill.game(); +}) + +ipcMain.on("kill-origin", () => { + kill.origin(); +}) // a simple function to kill processes with a certain name async function kill(process_name) { @@ -9,13 +18,13 @@ async function kill(process_name) { case "linux": return "killall -9 " + proc; case "win32": return "taskkill /IM " + proc + " /F"; } - })(); + })() exec(cmd, (err, stdout) => { // just try and fail silently if we don't find it w/e resolve(true); - }); - }); + }) + }) } kill.process = kill; |