mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
Electron-26 (Auto Launch for Mac) (#109)
* Electron-19 - Updated AutoLauncher path to make it work properly in mac * Electron-26 - Implemented auto launch for mac * Electron-26 - Added comments
This commit is contained in:
parent
307b60dd25
commit
8e8b3948da
@ -7,7 +7,7 @@ const squirrelStartup = require('electron-squirrel-startup');
|
||||
const AutoLaunch = require('auto-launch');
|
||||
const urlParser = require('url');
|
||||
const { getConfigField } = require('./config.js');
|
||||
const { isDevEnv} = require('./utils/misc.js');
|
||||
const { isMac, isDevEnv } = require('./utils/misc.js');
|
||||
const protocolHandler = require('./protocolHandler');
|
||||
|
||||
// used to check if a url was opened when the app was already open
|
||||
@ -93,7 +93,7 @@ function setupThenOpenMainWindow() {
|
||||
process.argv.some((val) => {
|
||||
|
||||
let flag = '--install';
|
||||
if (val === flag) {
|
||||
if (val === flag && !isMac) {
|
||||
installMode = true;
|
||||
getConfigField('launchOnStartup')
|
||||
.then(setStartup)
|
||||
|
@ -4,6 +4,7 @@ const electron = require('electron');
|
||||
const { getConfigField, updateConfigField } = require('../config.js');
|
||||
const AutoLaunch = require('auto-launch');
|
||||
const isMac = require('../utils/misc.js').isMac;
|
||||
const childProcess = require('child_process');
|
||||
|
||||
var minimizeOnClose = false;
|
||||
var launchOnStartup = false;
|
||||
@ -14,6 +15,7 @@ var symphonyAutoLauncher = new AutoLaunch({
|
||||
name: 'Symphony',
|
||||
path: process.execPath,
|
||||
});
|
||||
let launchAgentPath = '~/Library/LaunchAgents/com.symphony.symphony-desktop.agent.plist';
|
||||
|
||||
const template = [
|
||||
{
|
||||
@ -184,17 +186,39 @@ function getTemplate(app) {
|
||||
checked: launchOnStartup,
|
||||
click: function (item) {
|
||||
if (item.checked){
|
||||
symphonyAutoLauncher.enable()
|
||||
.catch(function (err) {
|
||||
let title = 'Error setting AutoLaunch configuration';
|
||||
electron.dialog.showErrorBox(title, title + ': ' + err);
|
||||
});
|
||||
if (isMac){
|
||||
// TODO: Need to change this implementation to AutoLaunch once they fix this issue ->
|
||||
// https://github.com/Teamwork/node-auto-launch/issues/28
|
||||
childProcess.exec(`launchctl load ${launchAgentPath}`, (err) => {
|
||||
if (err){
|
||||
let title = 'Error setting AutoLaunch configuration';
|
||||
electron.dialog.showErrorBox(title, 'Please try reinstalling the application');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
symphonyAutoLauncher.enable()
|
||||
.catch(function (err) {
|
||||
let title = 'Error setting AutoLaunch configuration';
|
||||
electron.dialog.showErrorBox(title, title + ': ' + err);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
symphonyAutoLauncher.disable()
|
||||
.catch(function (err) {
|
||||
let title = 'Error setting AutoLaunch configuration';
|
||||
electron.dialog.showErrorBox(title, title + ': ' + err);
|
||||
});
|
||||
if (isMac){
|
||||
// TODO: Need to change this implementation to AutoLaunch once they fix this issue ->
|
||||
// https://github.com/Teamwork/node-auto-launch/issues/28
|
||||
childProcess.exec(`launchctl unload ${launchAgentPath}`, (err) => {
|
||||
if (err){
|
||||
let title = 'Error disabling AutoLaunch configuration';
|
||||
electron.dialog.showErrorBox(title, 'Please try reinstalling the application');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
symphonyAutoLauncher.disable()
|
||||
.catch(function (err) {
|
||||
let title = 'Error setting AutoLaunch configuration';
|
||||
electron.dialog.showErrorBox(title, title + ': ' + err);
|
||||
});
|
||||
}
|
||||
}
|
||||
launchOnStartup = item.checked;
|
||||
updateConfigField('launchOnStartup', launchOnStartup);
|
||||
|
Loading…
Reference in New Issue
Block a user