mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
Electron-109 - Changed "launchOnStartup" custom implementation to "auto-launch"
This commit is contained in:
parent
7ac42f0f54
commit
598f75038b
@ -18,33 +18,10 @@ sed -i "" -E "s#\"minimizeOnClose\" ?: ?([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee])#
|
|||||||
sed -i "" -E "s#\"alwaysOnTop\" ?: ?([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee])#\"alwaysOnTop\":\ $always_on_top#g" $newPath
|
sed -i "" -E "s#\"alwaysOnTop\" ?: ?([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee])#\"alwaysOnTop\":\ $always_on_top#g" $newPath
|
||||||
sed -i "" -E "s#\"launchOnStartup\" ?: ?([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee])#\"launchOnStartup\":\ $launch_on_startup#g" $newPath
|
sed -i "" -E "s#\"launchOnStartup\" ?: ?([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee])#\"launchOnStartup\":\ $launch_on_startup#g" $newPath
|
||||||
|
|
||||||
## Add app to login items
|
|
||||||
if [ $launch_on_startup == true ]; then
|
|
||||||
mkdir ~/Library/LaunchAgents/
|
|
||||||
cat > ~/Library/LaunchAgents/com.symphony.symphony-desktop.agent.plist << EOT
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
||||||
<plist version="1.0">
|
|
||||||
<dict>
|
|
||||||
<key>Label</key>
|
|
||||||
<string>com.symphony.symphony-desktop.agent</string>
|
|
||||||
<key>ProgramArguments</key>
|
|
||||||
<array>
|
|
||||||
<string>$installPath/Symphony.app/Contents/MacOS/Symphony</string>
|
|
||||||
</array>
|
|
||||||
<key>RunAtLoad</key>
|
|
||||||
<true/>
|
|
||||||
</dict>
|
|
||||||
</plist>
|
|
||||||
EOT
|
|
||||||
else
|
|
||||||
launchctl unload ~/Library/LaunchAgents/com.symphony.symphony-desktop.agent.plist
|
|
||||||
fi
|
|
||||||
|
|
||||||
## Remove the temp settings file created ##
|
## Remove the temp settings file created ##
|
||||||
rm -f $tempFilePath
|
rm -f $tempFilePath
|
||||||
|
|
||||||
## For launching symphony with sandbox enabled, create a shell script that is used as the launch point for the app
|
## For launching symphony with sandbox enabled, create a shell script that is used as the launch point for the app
|
||||||
EXEC_PATH=$installPath/Symphony.app/Contents/MacOS
|
EXEC_PATH=$installPath/Symphony.app/Contents/MacOS
|
||||||
exec $EXEC_PATH/Symphony --install $newPath
|
exec $EXEC_PATH/Symphony --install $newPath $launch_on_startup
|
||||||
chmod 755 $EXEC_PATH/Symphony
|
chmod 755 $EXEC_PATH/Symphony
|
||||||
|
25
js/main.js
25
js/main.js
@ -51,10 +51,22 @@ if (!isDevEnv && shouldQuit) {
|
|||||||
app.quit();
|
app.quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
var symphonyAutoLauncher = new AutoLaunch({
|
let symphonyAutoLauncher;
|
||||||
name: 'Symphony',
|
|
||||||
path: process.execPath,
|
if (isMac) {
|
||||||
});
|
symphonyAutoLauncher = new AutoLaunch({
|
||||||
|
name: 'Symphony',
|
||||||
|
mac: {
|
||||||
|
useLaunchAgent: true,
|
||||||
|
},
|
||||||
|
path: process.execPath,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
symphonyAutoLauncher = new AutoLaunch({
|
||||||
|
name: 'Symphony',
|
||||||
|
path: process.execPath,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will be called when Electron has finished
|
* This method will be called when Electron has finished
|
||||||
@ -107,7 +119,12 @@ function setupThenOpenMainWindow() {
|
|||||||
|
|
||||||
// allows mac installer to overwrite user config
|
// allows mac installer to overwrite user config
|
||||||
if (isMac && hasInstallFlag) {
|
if (isMac && hasInstallFlag) {
|
||||||
|
// This value is being sent from post install script
|
||||||
|
// as the app is launched as a root user we don't get
|
||||||
|
// access to the config file
|
||||||
|
let launchOnStartup = process.argv[3];
|
||||||
updateUserConfigMac()
|
updateUserConfigMac()
|
||||||
|
.then(setStartup(launchOnStartup))
|
||||||
.then(app.quit)
|
.then(app.quit)
|
||||||
.catch(app.quit);
|
.catch(app.quit);
|
||||||
return;
|
return;
|
||||||
|
@ -4,7 +4,6 @@ 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');
|
|
||||||
const log = require('../log.js');
|
const log = require('../log.js');
|
||||||
const logLevels = require('../enums/logLevels.js');
|
const logLevels = require('../enums/logLevels.js');
|
||||||
const eventEmitter = require('../eventEmitter');
|
const eventEmitter = require('../eventEmitter');
|
||||||
@ -15,11 +14,22 @@ var isAlwaysOnTop = false;
|
|||||||
|
|
||||||
setCheckboxValues();
|
setCheckboxValues();
|
||||||
|
|
||||||
var symphonyAutoLauncher = new AutoLaunch({
|
let symphonyAutoLauncher;
|
||||||
name: 'Symphony',
|
|
||||||
path: process.execPath,
|
if (isMac) {
|
||||||
});
|
symphonyAutoLauncher = new AutoLaunch({
|
||||||
let launchAgentPath = '~/Library/LaunchAgents/com.symphony.symphony-desktop.agent.plist';
|
name: 'Symphony',
|
||||||
|
mac: {
|
||||||
|
useLaunchAgent: true,
|
||||||
|
},
|
||||||
|
path: process.execPath,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
symphonyAutoLauncher = new AutoLaunch({
|
||||||
|
name: 'Symphony',
|
||||||
|
path: process.execPath,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const template = [
|
const template = [
|
||||||
{
|
{
|
||||||
@ -190,43 +200,19 @@ function getTemplate(app) {
|
|||||||
checked: launchOnStartup,
|
checked: launchOnStartup,
|
||||||
click: function (item) {
|
click: function (item) {
|
||||||
if (item.checked){
|
if (item.checked){
|
||||||
if (isMac){
|
symphonyAutoLauncher.enable()
|
||||||
// TODO: Need to change this implementation to AutoLaunch once they fix this issue ->
|
.catch(function (err) {
|
||||||
// https://github.com/Teamwork/node-auto-launch/issues/28
|
let title = 'Error setting AutoLaunch configuration';
|
||||||
childProcess.exec(`launchctl load ${launchAgentPath}`, (err) => {
|
log.send(logLevels.ERROR, 'MenuTemplate: ' + title + ': auto launch error ' + err);
|
||||||
if (err){
|
electron.dialog.showErrorBox(title, title + ': ' + err);
|
||||||
let title = 'Error setting AutoLaunch configuration';
|
|
||||||
log.send(logLevels.ERROR, 'MenuTemplate: ' + title + ': process error ' + err);
|
|
||||||
electron.dialog.showErrorBox(title, 'Please try reinstalling the application');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
symphonyAutoLauncher.enable()
|
|
||||||
.catch(function (err) {
|
|
||||||
let title = 'Error setting AutoLaunch configuration';
|
|
||||||
log.send(logLevels.ERROR, 'MenuTemplate: ' + title + ': auto launch error ' + err);
|
|
||||||
electron.dialog.showErrorBox(title, title + ': ' + err);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (isMac){
|
symphonyAutoLauncher.disable()
|
||||||
// TODO: Need to change this implementation to AutoLaunch once they fix this issue ->
|
.catch(function (err) {
|
||||||
// https://github.com/Teamwork/node-auto-launch/issues/28
|
let title = 'Error setting AutoLaunch configuration';
|
||||||
childProcess.exec(`launchctl unload ${launchAgentPath}`, (err) => {
|
log.send(logLevels.ERROR, 'MenuTemplate: ' + title + ': auto launch error ' + err);
|
||||||
if (err){
|
electron.dialog.showErrorBox(title, title + ': ' + err);
|
||||||
let title = 'Error disabling AutoLaunch configuration';
|
|
||||||
log.send(logLevels.ERROR, 'MenuTemplate: ' + title + ': process error ' + err);
|
|
||||||
electron.dialog.showErrorBox(title, 'Please try reinstalling the application');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
symphonyAutoLauncher.disable()
|
|
||||||
.catch(function (err) {
|
|
||||||
let title = 'Error setting AutoLaunch configuration';
|
|
||||||
log.send(logLevels.ERROR, 'MenuTemplate: ' + title + ': auto launch error ' + 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