Skip to content

Commit 0d41c76

Browse files
committed
fix: prefix arguments with --args
1 parent 4bbf70a commit 0d41c76

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

apps/finicky/src/browser/launcher.go

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ func LaunchBrowser(config BrowserConfig, dryRun bool, openInBackgroundByDefault
5555
openArgs = []string{"-a", config.Name}
5656
}
5757

58-
5958
var openInBackground bool = openInBackgroundByDefault
6059

6160
if config.OpenInBackground != nil {
@@ -66,19 +65,33 @@ func LaunchBrowser(config BrowserConfig, dryRun bool, openInBackgroundByDefault
6665
openArgs = append(openArgs, "-g")
6766
}
6867

69-
if len(config.Args) == 0 {
68+
// Handle profile and custom args
69+
profileArgument, ok := resolveBrowserProfileArgument(config.Name, config.Profile)
70+
hasCustomArgs := len(config.Args) > 0
71+
72+
// Add -n flag if profile is used (required for profile switching)
73+
if ok {
74+
openArgs = append(openArgs, "-n")
75+
}
76+
77+
// Add --args if we have profile args or custom args
78+
if ok || hasCustomArgs {
79+
openArgs = append(openArgs, "--args")
7080

71-
profileArgument, ok := resolveBrowserProfileArgument(config.Name, config.Profile)
72-
if ok && profileArgument != "" {
73-
// FIXME: This is a hack to get the profile argument to work – this won't work for Firefox
74-
openArgs = append(openArgs, "-n")
75-
openArgs = append(openArgs, "--args")
81+
// Add profile argument first if present
82+
if ok {
7683
openArgs = append(openArgs, profileArgument)
7784
}
7885

79-
openArgs = append(openArgs, config.URL)
86+
// Add custom args or URL
87+
if hasCustomArgs {
88+
openArgs = append(openArgs, config.Args...)
89+
} else {
90+
openArgs = append(openArgs, config.URL)
91+
}
8092
} else {
81-
openArgs = append(openArgs, config.Args...)
93+
// No special args, just add the URL
94+
openArgs = append(openArgs, config.URL)
8295
}
8396

8497
cmd := exec.Command("open", openArgs...)

0 commit comments

Comments
 (0)