add logger
All checks were successful
Build Slideshow App / build (amd64, .exe, windows) (push) Successful in 2m7s
Build Slideshow App / build (amd64, , linux) (push) Successful in 2m25s
Build Slideshow App / build (arm, 7, , linux) (push) Successful in 2m2s
Build Slideshow App / build (arm64, , linux) (push) Successful in 2m1s

This commit is contained in:
Adrian Zürcher
2026-01-18 21:00:53 +01:00
parent 8165b2d843
commit 3241429e98
6 changed files with 57 additions and 6 deletions

View File

@@ -5,13 +5,17 @@ import (
"os"
"os/exec"
"runtime"
"strings"
"gitea.tecamino.com/paadi/tecamino-logger/logging"
)
func OpenBrowser(url string) error {
func OpenBrowser(logger *logging.Logger, url string) error {
var commands [][]string
switch runtime.GOOS {
case "windows":
logger.Debug("OpenBrowser", "os: windows")
commands = [][]string{
// Chrome (most common)
{`C:\Program Files\Google\Chrome\Application\chrome.exe`, "--kiosk", url},
@@ -30,6 +34,7 @@ func OpenBrowser(url string) error {
}
case "darwin":
logger.Debug("OpenBrowser", "os: windows")
commands = [][]string{
// Chrome
{"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", "--kiosk", url},
@@ -48,6 +53,7 @@ func OpenBrowser(url string) error {
}
default: // Linux
logger.Debug("OpenBrowser", "os: linux")
if os.Getenv("DISPLAY") == "" &&
os.Getenv("WAYLAND_DISPLAY") == "" &&
os.Getenv("XDG_SESSION_TYPE") != "wayland" {
@@ -71,6 +77,7 @@ func OpenBrowser(url string) error {
for _, cmd := range commands {
execCmd := exec.Command(cmd[0], cmd[1:]...)
if err := execCmd.Start(); err == nil {
logger.Debug("OpenBrowser", "browser started with command: "+strings.Join(cmd, ", "))
return nil
} else {
return err