mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-07-17 16:37:43 +00:00
Suppress noisy "EXITING due to failed single instance lock" message when a second instance is launched via xdg-open for protocol URL handling. Register superproductivity:// as a MIME type handler in the .desktop file so Linux users no longer need manual xdg-settings configuration. Remove duplicate requestSingleInstanceLock() call in start-app.ts. Closes #173
24 lines
784 B
TypeScript
24 lines
784 B
TypeScript
import { app } from 'electron';
|
|
import { PROTOCOL_PREFIX } from './protocol-handler';
|
|
import { startApp } from './start-app';
|
|
|
|
const IS_MAC = process.platform === 'darwin';
|
|
|
|
if (!IS_MAC) {
|
|
// make it a single instance by closing other instances but allow for dev mode
|
|
// because of https://github.com/electron/electron/issues/14094
|
|
const isLockObtained = app.requestSingleInstanceLock();
|
|
if (!isLockObtained) {
|
|
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 {
|
|
console.log('Start app...');
|
|
startApp();
|
|
}
|
|
} else {
|
|
startApp();
|
|
}
|