diff --git a/electron-builder.yaml b/electron-builder.yaml index 6d6cc84845..9f19321525 100644 --- a/electron-builder.yaml +++ b/electron-builder.yaml @@ -47,6 +47,8 @@ linux: # Fix for issue #5259: Set executable name without spaces for snap compatibility executableName: superproductivity category: Office;ProjectManagement + mimeTypes: + - x-scheme-handler/superproductivity desktop: entry: StartupWMClass: superproductivity diff --git a/electron/main.ts b/electron/main.ts index 24f060439b..c71cbfd57f 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -1,4 +1,5 @@ import { app } from 'electron'; +import { PROTOCOL_PREFIX } from './protocol-handler'; import { startApp } from './start-app'; const IS_MAC = process.platform === 'darwin'; @@ -8,7 +9,10 @@ if (!IS_MAC) { // because of https://github.com/electron/electron/issues/14094 const isLockObtained = app.requestSingleInstanceLock(); if (!isLockObtained) { - console.log('EXITING due to failed single instance lock'); + const hasProtocolUrl = process.argv.some((arg) => arg.startsWith(PROTOCOL_PREFIX)); + if (!hasProtocolUrl) { + console.log('Another instance is already running. Exiting.'); + } // Force immediate exit without waiting for graceful shutdown process.exit(0); } else { diff --git a/electron/start-app.ts b/electron/start-app.ts index ec8b2101e9..ba96447e36 100644 --- a/electron/start-app.ts +++ b/electron/start-app.ts @@ -51,19 +51,9 @@ let mainWin: BrowserWindow; let idleTimeHandler: IdleTimeHandler; export const startApp = (): void => { - // Initialize protocol handling + // Initialize protocol handling (registers second-instance listener for URL forwarding) initializeProtocolHandling(IS_DEV, app, () => mainWin); - // Handle single instance lock (not needed on macOS - OS handles it natively, - // and the singleton socket is blocked by the App Store sandbox) - if (!IS_MAC) { - const gotTheLock = app.requestSingleInstanceLock(); - if (!gotTheLock) { - app.quit(); - return; - } - } - // LOAD IPC STUFF initIpcInterfaces();