From c9bd5ad48838779e9608034adb29e2a1fdac6234 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Thu, 12 Oct 2017 18:04:31 -0400 Subject: [PATCH] Use Single Instance App mode on Linux This Electron feature now works on Linux again as of Electron 1.7.8. Fixes #164 (multiple windows opening on Linux when clicking lbry:// links) --- app/main.js | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/app/main.js b/app/main.js index 4bc9944df..e51928139 100644 --- a/app/main.js +++ b/app/main.js @@ -227,24 +227,20 @@ function quitNow() { app.quit(); } -if (process.platform != 'linux') { - // On Linux, this is always returning true due to an Electron bug, - // so for now we just don't support single-instance apps on Linux. - const isSecondaryInstance = app.makeSingleInstance((argv) => { - if (argv.length >= 2) { - handleOpenUriRequested(argv[1]); // This will handle restoring and focusing the window - } else if (win) { - if (win.isMinimized()) { - win.restore(); - } - win.focus(); +const isSecondaryInstance = app.makeSingleInstance((argv) => { + if (argv.length >= 2) { + handleOpenUriRequested(argv[1]); // This will handle restoring and focusing the window + } else if (win) { + if (win.isMinimized()) { + win.restore(); } - }); - - if (isSecondaryInstance) { // We're not in the original process, so quit - quitNow(); - return; + win.focus(); } +}); + +if (isSecondaryInstance) { // We're not in the original process, so quit + quitNow(); + return; } app.on('ready', function(){