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 AutoLaunch = require('auto-launch');
|
||||||
const urlParser = require('url');
|
const urlParser = require('url');
|
||||||
const { getConfigField } = require('./config.js');
|
const { getConfigField } = require('./config.js');
|
||||||
const { isDevEnv} = require('./utils/misc.js');
|
const { isMac, isDevEnv } = require('./utils/misc.js');
|
||||||
const protocolHandler = require('./protocolHandler');
|
const protocolHandler = require('./protocolHandler');
|
||||||
|
|
||||||
// used to check if a url was opened when the app was already open
|
// used to check if a url was opened when the app was already open
|
||||||
@ -93,7 +93,7 @@ function setupThenOpenMainWindow() {
|
|||||||
process.argv.some((val) => {
|
process.argv.some((val) => {
|
||||||
|
|
||||||
let flag = '--install';
|
let flag = '--install';
|
||||||
if (val === flag) {
|
if (val === flag && !isMac) {
|
||||||
installMode = true;
|
installMode = true;
|
||||||
getConfigField('launchOnStartup')
|
getConfigField('launchOnStartup')
|
||||||
.then(setStartup)
|
.then(setStartup)
|
||||||
|
@ -4,6 +4,7 @@ const electron = require('electron');
|
|||||||
const { getConfigField, updateConfigField } = require('../config.js');
|
const { getConfigField, updateConfigField } = require('../config.js');
|
||||||
const AutoLaunch = require('auto-launch');
|
const AutoLaunch = require('auto-launch');
|
||||||
const isMac = require('../utils/misc.js').isMac;
|
const isMac = require('../utils/misc.js').isMac;
|
||||||
|
const childProcess = require('child_process');
|
||||||
|
|
||||||
var minimizeOnClose = false;
|
var minimizeOnClose = false;
|
||||||
var launchOnStartup = false;
|
var launchOnStartup = false;
|
||||||
@ -14,6 +15,7 @@ var symphonyAutoLauncher = new AutoLaunch({
|
|||||||
name: 'Symphony',
|
name: 'Symphony',
|
||||||
path: process.execPath,
|
path: process.execPath,
|
||||||
});
|
});
|
||||||
|
let launchAgentPath = '~/Library/LaunchAgents/com.symphony.symphony-desktop.agent.plist';
|
||||||
|
|
||||||
const template = [
|
const template = [
|
||||||
{
|
{
|
||||||
@ -184,11 +186,32 @@ function getTemplate(app) {
|
|||||||
checked: launchOnStartup,
|
checked: launchOnStartup,
|
||||||
click: function (item) {
|
click: function (item) {
|
||||||
if (item.checked){
|
if (item.checked){
|
||||||
|
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()
|
symphonyAutoLauncher.enable()
|
||||||
.catch(function (err) {
|
.catch(function (err) {
|
||||||
let title = 'Error setting AutoLaunch configuration';
|
let title = 'Error setting AutoLaunch configuration';
|
||||||
electron.dialog.showErrorBox(title, title + ': ' + err);
|
electron.dialog.showErrorBox(title, title + ': ' + err);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
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 {
|
} else {
|
||||||
symphonyAutoLauncher.disable()
|
symphonyAutoLauncher.disable()
|
||||||
.catch(function (err) {
|
.catch(function (err) {
|
||||||
@ -196,6 +219,7 @@ function getTemplate(app) {
|
|||||||
electron.dialog.showErrorBox(title, title + ': ' + err);
|
electron.dialog.showErrorBox(title, title + ': ' + err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
launchOnStartup = item.checked;
|
launchOnStartup = item.checked;
|
||||||
updateConfigField('launchOnStartup', launchOnStartup);
|
updateConfigField('launchOnStartup', launchOnStartup);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user