Merge pull request #1920 from BlueManCZ/tray-fix

Improve libappindicator checking
This commit is contained in:
Alex
2021-02-01 18:37:13 +01:00
committed by GitHub

View File

@@ -44,23 +44,15 @@ function initWin32 () {
} }
/** /**
* Check for libappindicator1 support before creating tray icon * Check for libappindicator support before creating tray icon.
*/ */
function checkLinuxTraySupport (cb) { function checkLinuxTraySupport (cb) {
const cp = require('child_process') const cp = require('child_process')
// Check that we're on Ubuntu (or another debian system) and that we have // Check that libappindicator libraries are installed in system.
// libappindicator1. If WebTorrent was installed from the deb file, we should cp.exec('ldconfig -p | grep libappindicator', function (err, stdout) {
// always have it. If it was installed from the zip file, we might not.
cp.exec('dpkg --get-selections libappindicator1', function (err, stdout) {
if (err) return cb(err) if (err) return cb(err)
// Unfortunately there's no cleaner way, as far as I can tell, to check cb(null)
// whether a debian package is installed:
if (stdout.endsWith('\tinstall\n')) {
cb(null)
} else {
cb(new Error('debian package not installed'))
}
}) })
} }