fix(control): sometimes could not start browser

This commit is contained in:
2026-01-15 15:16:02 +01:00
parent 662bcb3b8d
commit e2a9558d3f
5 changed files with 9 additions and 12 deletions
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -64,7 +64,7 @@ func main() {
os.Exit(1)
}
}()
err = shared.OpenBrowserWindow("http://localhost:"+port, false, false)
err = shared.OpenBrowserWindow("http://localhost:"+port, false)
if err != nil {
slog.Error("Failed to open browser window", "error", err)
os.Exit(1)
+1 -1
View File
@@ -26,7 +26,7 @@ func main() {
// the order is important, the open browser command exitsts as soon as the winodw is closed
// and since its the last action in the main go func all other goroutines (e.g. the webserver) are killed
go web.StartWebServer(shared.Version, port)
err = shared.OpenBrowserWindow("http://localhost:"+port, true, true)
err = shared.OpenBrowserWindow("http://localhost:"+port, true)
if err != nil {
slog.Error("Failed to open browser window", "error", err)
os.Exit(1)
+1
View File
@@ -7,6 +7,7 @@ golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457/go.mod h1:pRgIJT+bRLFKnoM1ldnzKoxTIn14Yxz928LQRYYgIN0=
golang.org/x/telemetry v0.0.0-20250710130107-8d8967aff50b/go.mod h1:4ZwOYna0/zsOKwuR5X/m0QFOJpSZvAxFfkQT+Erd9D4=
golang.org/x/telemetry v0.0.0-20251111182119-bc8e575c7b54/go.mod h1:hKdjCMrbv9skySur+Nek8Hd0uJ0GuxJIoIX2payrIdQ=
golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ=
golang.org/x/term v0.33.0/go.mod h1:s18+ql9tYWp1IfpV9DmCtQDDSRBUjKaw9M1eAv5UeF0=
golang.org/x/term v0.38.0/go.mod h1:bSEAKrOT1W+VSu9TSCMtoGEOUcKxOKgl3LE5QEF/xVg=
+4 -8
View File
@@ -7,20 +7,16 @@ import (
"os/exec"
)
func OpenBrowserWindow(url string, fullscreen bool, temp bool) error {
func OpenBrowserWindow(url string, fullscreen bool) error {
bins := []string{"chromium", "chromium-browser"}
args := []string{fmt.Sprintf("--app=%s", url), "--autoplay-policy=no-user-gesture-required"}
if fullscreen {
args = append(args, "--start-fullscreen")
}
if temp {
tempDirPath, err := os.MkdirTemp("", "plg-mudics-browser-")
if err != nil {
return err
}
arg := fmt.Sprintf("--user-data-dir=%s", tempDirPath)
args = append(args, arg)
args := []string{fmt.Sprintf("--app=%s", url), "--autoplay-policy=no-user-gesture-required", fmt.Sprintf("--user-data-dir=%s", tempDirPath)}
if fullscreen {
args = append(args, "--start-fullscreen")
}
errs := []string{}