Skip to content

armgit / plexo

Public Imported from GitHub
0

Speed up downloads by combining multiple network connections in parallel

Let Windows users choose the install folder and opt out of the desktop shortcut

prashantgeek97fdcc08082f
diff --git a/build/installer.nsh b/build/installer.nsh
new file mode 100644
index 0000000..774dc32
--- /dev/null
+++ b/build/installer.nsh
@@ -0,0 +1,51 @@
+# Custom NSIS hooks, picked up automatically by electron-builder from build/installer.nsh.
+
+# Replaces electron-builder's default finish page (assistedInstaller.nsh) to add a
+# "Create a desktop shortcut" checkbox, checked by default. The install step has already created
+# the shortcut (createDesktopShortcut in electron-builder.yml), so the checkbox only decides whether
+# it stays: unchecked deletes it, checked recreates it if an earlier install left it missing.
+# Silent installs and auto-updates skip this page and keep the default behaviour.
+!macro customFinishPage
+ # Same "Run Plexo" checkbox as the default finish page.
+ !ifndef HIDE_RUN_AFTER_FINISH
+ Function StartApp
+ ${if} ${isUpdated}
+ StrCpy $1 "--updated"
+ ${else}
+ StrCpy $1 ""
+ ${endif}
+ ${StdUtils.ExecShellAsUser} $0 "$launchLink" "open" "$1"
+ FunctionEnd
+
+ !define MUI_FINISHPAGE_RUN
+ !define MUI_FINISHPAGE_RUN_FUNCTION "StartApp"
+ !endif
+
+ # Called by the finish page only when the checkbox is checked.
+ Function CreateDesktopShortcut
+ ${ifNot} ${FileExists} "$newDesktopLink"
+ CreateShortCut "$newDesktopLink" "$appExe" "" "$appExe" 0 "" "" "${APP_DESCRIPTION}"
+ ClearErrors
+ WinShell::SetLnkAUMI "$newDesktopLink" "${APP_ID}"
+ System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
+ ${endIf}
+ FunctionEnd
+
+ # Runs when the user clicks Finish, before the checkbox actions above.
+ Function RemoveDesktopShortcutIfUnchecked
+ ${NSD_GetState} $mui.FinishPage.ShowReadme $0
+ ${if} $0 <> ${BST_CHECKED}
+ WinShell::UninstShortcut "$newDesktopLink"
+ Delete "$newDesktopLink"
+ System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
+ ${endIf}
+ FunctionEnd
+
+ # MUI only offers a "Show Readme" checkbox here; we relabel it and point it at our function.
+ !define MUI_FINISHPAGE_SHOWREADME ""
+ !define MUI_FINISHPAGE_SHOWREADME_TEXT "Create a desktop shortcut"
+ !define MUI_FINISHPAGE_SHOWREADME_FUNCTION "CreateDesktopShortcut"
+ !define MUI_PAGE_CUSTOMFUNCTION_LEAVE "RemoveDesktopShortcutIfUnchecked"
+
+ !insertmacro MUI_PAGE_FINISH
+!macroend
diff --git a/electron-builder.yml b/electron-builder.yml
index c2869e8..7c70b9b 100644
--- a/electron-builder.yml
+++ b/electron-builder.yml
@@ -23,6 +23,10 @@ nsis:
# No ${arch} on purpose: one installer holds both x64 and ARM64, and docs/downloads.js reads an
# installer with no architecture in its name as exactly that. Add one here and update it there.
artifactName: ${name}-${version}-setup.${ext}
+ # Assisted installer instead of one-click, so users can choose the install folder (and drive).
+ # One-click always installs to %LOCALAPPDATA%\Programs with no way to change it.
+ oneClick: false
+ allowToChangeInstallationDirectory: true
shortcutName: ${productName}
uninstallDisplayName: ${productName}
createDesktopShortcut: always