From 7e5db8719067401f21af5f70d4e385d546e97abf Mon Sep 17 00:00:00 2001 From: pompurin404 Date: Tue, 24 Sep 2024 23:59:42 +0800 Subject: [PATCH] fix linux relaunch sandbox --- src/main/index.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/index.ts b/src/main/index.ts index a8287c55..7b2f7c26 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -10,7 +10,7 @@ import { createTray } from './resolve/tray' import { init } from './utils/init' import { join } from 'path' import { initShortcut } from './resolve/shortcut' -import { execSync } from 'child_process' +import { execSync, spawn } from 'child_process' import { createElevateTask } from './sys/misc' import { initProfileUpdater } from './core/profileUpdater' import { existsSync, writeFileSync } from 'fs' @@ -48,6 +48,18 @@ if (!gotTheLock) { app.quit() } +export function customRelaunch(): void { + spawn('sh', ['-c', `"sleep 1 && ${process.argv.join(' ')} & disown && exit"`], { + shell: true, + detached: true, + stdio: 'ignore' + }) +} + +if (process.platform === 'linux') { + app.relaunch = customRelaunch +} + if (process.platform === 'win32') { // https://github.com/electron/electron/issues/43278 // https://github.com/electron/electron/issues/36698