From a07b87fc206a625de2cdb5bc9395a89a6542944d Mon Sep 17 00:00:00 2001
From: Daniel <dhaavi@users.noreply.github.com>
Date: Thu, 1 Aug 2024 14:16:18 +0200
Subject: [PATCH] [cmd/start] Compile cmdline args after possibly upgrading to
 new UI

---
 cmds/portmaster-start/run.go | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/cmds/portmaster-start/run.go b/cmds/portmaster-start/run.go
index 8cbea78e..f807fd69 100644
--- a/cmds/portmaster-start/run.go
+++ b/cmds/portmaster-start/run.go
@@ -154,7 +154,7 @@ func getExecArgs(opts *Options, cmdArgs []string) []string {
 		args = append(args, "--input-signals")
 	}
 
-	if runtime.GOOS == "linux" && opts.Identifier == "app/portmaster-app.zip" {
+	if runtime.GOOS == "linux" && opts.ShortIdentifier == "app" {
 		// see https://www.freedesktop.org/software/systemd/man/pam_systemd.html#type=
 		if xdgSessionType := os.Getenv("XDG_SESSION_TYPE"); xdgSessionType == "wayland" {
 			// we're running the Portmaster UI App under Wayland so make sure we add some arguments
@@ -180,10 +180,6 @@ func run(opts *Options, cmdArgs []string) (err error) {
 		return nil
 	}
 
-	// get original arguments
-	// additional parameters can be specified using -- --some-parameter
-	args := getExecArgs(opts, cmdArgs)
-
 	// check for duplicate instances
 	if opts.PIDFile {
 		pid, err := checkAndCreateInstanceLock(opts.LockPathPrefix, opts.ShortIdentifier, opts.LockPerUser)
@@ -226,7 +222,7 @@ func run(opts *Options, cmdArgs []string) (err error) {
 		}
 	}
 
-	return runAndRestart(opts, args)
+	return runAndRestart(opts, cmdArgs)
 }
 
 func runAndRestart(opts *Options, args []string) error {
@@ -342,6 +338,10 @@ func execute(opts *Options, args []string) (cont bool, err error) {
 		opts = &app2Options
 	}
 
+	// Compile arguments and add additional arguments based on system configuration.
+	// Extra parameters can be specified using "-- --some-parameter".
+	args = getExecArgs(opts, args)
+
 	file, err := registry.GetFile(
 		helper.PlatformIdentifier(opts.Identifier),
 	)