diff --git a/electron-builder.json b/electron-builder.json index baecbb56ea2..0addff49a17 100644 --- a/electron-builder.json +++ b/electron-builder.json @@ -46,7 +46,8 @@ "target": "deb", "category": "AudioVideo;Video", "desktop": { - "MimeType": "x-scheme-handler/lbry;" + "MimeType": "x-scheme-handler/lbry", + "Exec": "/opt/LBRY/lbry %U" } }, "deb": { diff --git a/src/main/createWindow.js b/src/main/createWindow.js index 57d4594529c..27af06c386d 100644 --- a/src/main/createWindow.js +++ b/src/main/createWindow.js @@ -33,8 +33,11 @@ export default appState => { window.loadURL(rendererURL); let deepLinkingURI; - // Protocol handler for win32 - if (process.platform === 'win32' && String(process.argv[1]).startsWith('lbry')) { + if ( + (process.platform === 'win32' || process.platform === 'linux') && + String(process.argv[1]).startsWith('lbry') + ) { + [, deepLinkingURI] = process.argv; // Keep only command line / deep linked arguments // Windows normalizes URIs when they're passed in from other apps. On Windows, this tries to // restore the original URI that was typed. @@ -42,8 +45,10 @@ export default appState => { // path, so we just strip it off. // - In a URI with a claim ID, like lbry://channel#claimid, Windows interprets the hash mark as // an anchor and converts it to lbry://channel/#claimid. We remove the slash here as well. - deepLinkingURI = process.argv[1].replace(/\/$/, '').replace('/#', '#'); - } else if (process.platform === 'darwin') { + if (process.platform === 'win32') { + deepLinkingURI = deepLinkingURI.replace(/\/$/, '').replace('/#', '#'); + } + } else { deepLinkingURI = appState.macDeepLinkingURI; } diff --git a/src/main/index.js b/src/main/index.js index 13381fc1c77..8b125042c85 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -218,16 +218,26 @@ process.on('uncaughtException', error => { // Force single instance application const isSecondInstance = app.makeSingleInstance(argv => { - // Protocol handler for win32 - // argv: An array of the second instance’s (command line / deep linked) arguments + if ( + (process.platform === 'win32' || process.platform === 'linux') && + String(argv[1]).startsWith('lbry') + ) { + let URI = argv[1]; - let URI; - if (process.platform === 'win32' && String(argv[1]).startsWith('lbry')) { // Keep only command line / deep linked arguments - URI = argv[1].replace(/\/$/, '').replace('/#', '#'); + // Windows normalizes URIs when they're passed in from other apps. On Windows, this tries to + // restore the original URI that was typed. + // - If the URI has no path, Windows adds a trailing slash. LBRY URIs can't have a slash with no + // path, so we just strip it off. + // - In a URI with a claim ID, like lbry://channel#claimid, Windows interprets the hash mark as + // an anchor and converts it to lbry://channel/#claimid. We remove the slash here as well. + if (process.platform === 'win32') { + URI = URI.replace(/\/$/, '').replace('/#', '#'); + } + + rendererWindow.webContents.send('open-uri-requested', URI); } - rendererWindow.webContents.send('open-uri-requested', URI); rendererWindow.show(); });