fix(backend): add no-cgo tray fallback for darwin and freebsd (#1691)
* refactor(backend): add darwin no-cgo tray fallback * fix(release): stub tray for freebsd builds without cgo
This commit is contained in:
parent
174fbba14c
commit
3e33d1053c
2 changed files with 34 additions and 1 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
//go:build !darwin || cgo
|
//go:build (!darwin && !freebsd) || cgo
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|
|
||||||
33
web/backend/tray_stub_nocgo.go
Normal file
33
web/backend/tray_stub_nocgo.go
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
//go:build (darwin || freebsd) && !cgo
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"runtime"
|
||||||
|
"syscall"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/sipeed/picoclaw/pkg/logger"
|
||||||
|
)
|
||||||
|
|
||||||
|
func runTray() {
|
||||||
|
logger.Infof("System tray is unavailable in %s builds without cgo; running without tray", runtime.GOOS)
|
||||||
|
|
||||||
|
if !*noBrowser {
|
||||||
|
go func() {
|
||||||
|
time.Sleep(browserDelay)
|
||||||
|
if err := openBrowser(); err != nil {
|
||||||
|
logger.Errorf("Warning: Failed to auto-open browser: %v", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
||||||
|
defer stop()
|
||||||
|
|
||||||
|
<-ctx.Done()
|
||||||
|
shutdownApp()
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue