From b1299a128310e4aa79832c26ee786ff9885f10e6 Mon Sep 17 00:00:00 2001 From: Vishwas Shashidhar Date: Tue, 7 Nov 2017 13:23:31 +0530 Subject: [PATCH 1/2] electron-201: fixes issue related to auto launch --- installer/mac/postinstall.sh | 23 +++++++++++++---------- js/main.js | 22 ++++++++-------------- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/installer/mac/postinstall.sh b/installer/mac/postinstall.sh index 3cfa3869..8f9f9424 100755 --- a/installer/mac/postinstall.sh +++ b/installer/mac/postinstall.sh @@ -4,24 +4,27 @@ tempFilePath='/tmp/sym_settings.txt' installPath="$2" configPath="/Symphony.app/Contents/config/Symphony.config" -newPath=$installPath$configPath +newPath=${installPath}${configPath} + +## Initial cleanup +sudo rm -f ~/Library/LaunchAgents/Symphony.plist ## Get Symphony Settings from the temp file ## -pod_url=$(sed -n '1p' $tempFilePath); +pod_url=$(sed -n '1p' ${tempFilePath}); minimize_on_close=$(sed -n '2p' '/tmp/sym_settings.txt'); launch_on_startup=$(sed -n '3p' '/tmp/sym_settings.txt'); always_on_top=$(sed -n '4p' '/tmp/sym_settings.txt'); ## Replace the default settings with the user selected settings ## -sed -i "" -E "s#\"url\" ?: ?\".*\"#\"url\"\: \"$pod_url\"#g" $newPath -sed -i "" -E "s#\"minimizeOnClose\" ?: ?([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee])#\"minimizeOnClose\":\ $minimize_on_close#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#\"url\" ?: ?\".*\"#\"url\"\: \"$pod_url\"#g" ${newPath} +sed -i "" -E "s#\"minimizeOnClose\" ?: ?([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee])#\"minimizeOnClose\":\ $minimize_on_close#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} ## 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 -EXEC_PATH=$installPath/Symphony.app/Contents/MacOS -exec $EXEC_PATH/Symphony --install $newPath $launch_on_startup -chmod 755 $EXEC_PATH/Symphony +EXEC_PATH=${installPath}/Symphony.app/Contents/MacOS +exec ${EXEC_PATH}/Symphony --install ${newPath} ${launch_on_startup} +chmod 755 ${EXEC_PATH}/Symphony diff --git a/js/main.js b/js/main.js index 80963a16..ed36388f 100644 --- a/js/main.js +++ b/js/main.js @@ -157,9 +157,8 @@ function setupThenOpenMainWindow() { let launchOnStartup = process.argv[3]; // We wire this in via the post install script // to get the config file path where the app is installed - let appGlobalConfigPath = process.argv[2]; setStartup(launchOnStartup) - .then(() => updateUserConfigMac(appGlobalConfigPath)) + .then(updateUserConfigMac) .then(app.quit) .catch(app.quit); return; @@ -178,18 +177,13 @@ function setupThenOpenMainWindow() { * @returns {Promise} */ function setStartup(lStartup) { - return symphonyAutoLauncher.isEnabled() - .then(function(isEnabled) { - if (!isEnabled && lStartup) { - return symphonyAutoLauncher.enable(); - } - - if (isEnabled && !lStartup) { - return symphonyAutoLauncher.disable(); - } - - return true; - }); + return new Promise((resolve) => { + let launchOnStartup = (lStartup === 'true'); + if (launchOnStartup) { + symphonyAutoLauncher.enable(); + } + return resolve(); + }); } /** From d8cc2531be53d7596a5b2e6daa2fd3baedda39fc Mon Sep 17 00:00:00 2001 From: Vishwas Shashidhar Date: Tue, 7 Nov 2017 13:31:45 +0530 Subject: [PATCH 2/2] electron-201: applied common changes for windows too --- installer/mac/postinstall.sh | 3 --- js/main.js | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/installer/mac/postinstall.sh b/installer/mac/postinstall.sh index 8f9f9424..a285adb4 100755 --- a/installer/mac/postinstall.sh +++ b/installer/mac/postinstall.sh @@ -6,9 +6,6 @@ installPath="$2" configPath="/Symphony.app/Contents/config/Symphony.config" newPath=${installPath}${configPath} -## Initial cleanup -sudo rm -f ~/Library/LaunchAgents/Symphony.plist - ## Get Symphony Settings from the temp file ## pod_url=$(sed -n '1p' ${tempFilePath}); minimize_on_close=$(sed -n '2p' '/tmp/sym_settings.txt'); diff --git a/js/main.js b/js/main.js index 7a6e855a..25ec0b5e 100644 --- a/js/main.js +++ b/js/main.js @@ -196,7 +196,9 @@ function setStartup(lStartup) { let launchOnStartup = (lStartup === 'true'); if (launchOnStartup) { symphonyAutoLauncher.enable(); + return resolve(); } + symphonyAutoLauncher.disable(); return resolve(); }); }