refactor(display): use chrome devtools protocol (#38)

This commit is contained in:
2026-01-30 15:26:57 +01:00
committed by GitHub
parent cbbf50e5a4
commit 71f152ef2a
24 changed files with 570 additions and 504 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ import (
)
//go:embed splash_screen.html
var SplashScreenTemplate string
var RawSplashScreenTemplate string
//go:embed version.txt
var versionNotTrimmed string
-45
View File
@@ -1,45 +0,0 @@
package shared
import (
"errors"
"fmt"
"os"
"os/exec"
"path/filepath"
)
func OpenBrowserWindow(url string, fullscreen bool, profile string) error {
bins := []string{"chromium", "chromium-browser"}
home, err := os.UserHomeDir()
if err != nil {
return fmt.Errorf("unable to determine user home directory: %w", err)
}
browserProfileDirPath := filepath.Join(home, ".local", "share", "plg-mudics", fmt.Sprintf("browser-%s", profile))
if err := os.MkdirAll(browserProfileDirPath, os.ModePerm); err != nil {
return fmt.Errorf("failed to create local config directory: %w", err)
}
args := []string{
fmt.Sprintf("--app=%s", url),
"--autoplay-policy=no-user-gesture-required",
fmt.Sprintf("--user-data-dir=%s", browserProfileDirPath),
"--allow-running-insecure-content",
"--disable-features=XFrameOptions",
}
if fullscreen {
args = append(args, "--start-fullscreen")
}
errs := []string{}
for _, bin := range bins {
cmd := exec.Command(bin, args...)
commandOutput := RunShellCommand(cmd)
if commandOutput.ExitCode == 0 {
return nil
}
errs = append(errs, commandOutput.Stderr)
}
return errors.New("failed to open browser window: " + fmt.Sprint(errs))
}