Rules-based browser launcher for TUI + GNOME. switchyard.aly.codes
tui gnome bowser go
0

Configure Feed

Select the types of activity you want to include in your feed.

fix: wrap browser cmdline with `sh -c` (#28)

authored by

Aly Raffauf and committed by
GitHub
(Jan 27, 2026, 3:30 PM EST) ef2f7b5b ea4b369e

+15 -15
+15 -15
src/launch.go
··· 30 30 cmdline = strings.ReplaceAll(cmdline, code, "") 31 31 } 32 32 33 - // Parse the command line 34 - parts := strings.Fields(cmdline) 33 + // Chromium-based desktop files are essentially broken, they include no logic for a URL to pass using typical means. In this case, we work around by appending our URL. 34 + if !hasFieldCode && url != "" { 35 + cmdline = cmdline + " " + url 36 + } 35 37 36 - // Chromium-based desktop files are essentially broken, they include no logic for a URL to pass using typical means. In this case, we work aorund by appending our URL. 37 - if !hasFieldCode && url != "" && len(parts) > 0 { 38 - parts = append(parts, url) 39 - } 40 - if len(parts) == 0 { 38 + if strings.TrimSpace(cmdline) == "" { 41 39 return nil 42 40 } 43 41 ··· 47 45 activationToken = display.AppLaunchContext().StartupNotifyID(appInfo, nil) 48 46 } 49 47 48 + var cmd *exec.Cmd 50 49 // When running in Flatpak, wrap with flatpak-spawn --host 51 50 // and pass activation token via --env flag 52 - if os.Getenv("FLATPAK_ID") != "" && !strings.HasPrefix(parts[0], "flatpak-spawn") { 53 - parts = append([]string{"flatpak-spawn", "--host", "--env=XDG_ACTIVATION_TOKEN=" + activationToken}, parts...) 51 + if os.Getenv("FLATPAK_ID") != "" && !strings.HasPrefix(cmdline, "flatpak-spawn") { 52 + cmd = exec.Command("flatpak-spawn", "--host", "--env=XDG_ACTIVATION_TOKEN="+activationToken, "sh", "-c", cmdline) 54 53 activationToken = "" // Already handled via flatpak-spawn 55 - } 56 - 57 - // Execute the command 58 - cmd := exec.Command(parts[0], parts[1:]...) 59 - if activationToken != "" { 60 - cmd.Env = append(os.Environ(), "XDG_ACTIVATION_TOKEN="+activationToken) 54 + } else { 55 + // let the shell handle quote parsing 56 + // https://github.com/alyraffauf/switchyard/issues/27 57 + cmd = exec.Command("sh", "-c", cmdline) 58 + if activationToken != "" { 59 + cmd.Env = append(os.Environ(), "XDG_ACTIVATION_TOKEN="+activationToken) 60 + } 61 61 } 62 62 63 63 if err := cmd.Start(); err != nil {