diff --git a/main.js b/main.js index 0fb0aed..8d17baa 100644 --- a/main.js +++ b/main.js @@ -7,7 +7,28 @@ const BrowserWindow = electron.BrowserWindow const path = require('path') // Open external urls in default browser -const open = require('open') +const open = function (target, appName, callback) { + var opener; + + if (typeof(appName) === 'function') { + callback = appName; + appName = null; + } + + if (appName) + opener = 'open -a "' + escape(appName) + '"'; + else + opener = 'open'; + + if (process.env.SUDO_USER) + opener = 'sudo -u ' + process.env.SUDO_USER + ' ' + opener; + + return exec(opener + ' "' + escape(target) + '"', callback); +} + +function escape(s) { + return s.replace(/"/g, '\\\"'); +} // Module to bind media shortcuts const globalShortcut = require('electron').globalShortcut diff --git a/package.json b/package.json index 53d930f..a266176 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,6 @@ "homepage": "http://scriptspry.com/2016/07/30/saavn-mac-app.html", "devDependencies": { "electron-packager": "^8.2.0", - "electron-prebuilt": "^1.4.5", - "open": "^0.0.5" + "electron-prebuilt": "^1.4.5" } }