Skip to content
This repository has been archived by the owner on May 2, 2022. It is now read-only.

Commit

Permalink
[CU-2a0ykrf] Fix app opening functionality doesn"t work on Linux (#1633)
Browse files Browse the repository at this point in the history
  • Loading branch information
quanglam2807 authored Feb 18, 2022
1 parent 3734fe9 commit 3991cbb
Show file tree
Hide file tree
Showing 2 changed files with 231 additions and 193 deletions.
17 changes: 14 additions & 3 deletions main-src/libs/app-management/open-app.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
const { app, shell } = require("electron");
const { app, shell, dialog } = require("electron");
const path = require('path');
const { exec } = require('child_process');
const fsExtra = require('fs-extra');

const { getPreference } = require('../preferences');
const mainWindow = require('../windows/main');

const openApp = (id, name) => {
if (process.platform === 'darwin') {
const appPath = path.join(getPreference('installationPath').replace('~', app.getPath('home')), `${name}.app`);
shell.openPath(appPath);
} else if (process.platform === 'linux') {
exec(`gtk-launch webcatalog-${id}`);
// for unknown reason, we can't launch Linux Electron binary with child_process
// regardless of launching the binary directly or through gtk-launch
// exec(`gtk-launch webcatalog-${id}`);
// so we show user how to open the app manually
// can open the binary manually
dialog.showMessageBox(mainWindow.get(), {
type: 'info',
message: `Please launch "${name}" manually using system app launcher.`,
buttons: ['OK'],
cancelId: 0,
defaultId: 0,
}).catch(console.log); // eslint-disable-line
} else if (process.platform === 'win32') {
const shortcutPath = path.join(getPreference('installationPath'), name, `${name}.lnk`);
if (fsExtra.existsSync(shortcutPath)) {
Expand Down
Loading

0 comments on commit 3991cbb

Please sign in to comment.