// Command behavision-desktop is the store-facing application: a tray icon, a // window, and the supervisor for the recognition engine. // // It is one process rather than three because the tray, the window and the // supervisor all need the same state, and because a user who quits the tray // expects recognition to stop. It is deliberately NOT a Windows service: a // service runs in session 0 and cannot draw a tray icon, and spawning a child // process needs no elevation while controlling a service does. package main import ( "context" "embed" "log" "github.com/wailsapp/wails/v2" "github.com/wailsapp/wails/v2/pkg/options" "github.com/wailsapp/wails/v2/pkg/options/assetserver" "github.com/wailsapp/wails/v2/pkg/options/windows" "github.com/wailsapp/wails/v2/pkg/runtime" ) //go:embed all:frontend/dist var assets embed.FS func main() { app := NewApp() tray := newTray(app) err := wails.Run(&options.App{ Title: "Behavision", Width: 1280, Height: 820, // Small enough to still be usable on a cramped shop-counter monitor. MinWidth: 1024, MinHeight: 640, AssetServer: &assetserver.Options{Assets: assets}, // Closing the window hides it rather than quitting: the engine must // keep recognising after a shop assistant clicks the X, and the tray // is where they get the window back. HideWindowOnClose: true, OnStartup: func(ctx context.Context) { app.startup(ctx) tray.start(ctx) }, OnBeforeClose: func(ctx context.Context) bool { runtime.Hide(ctx) return true // prevent the close }, OnShutdown: func(ctx context.Context) { tray.stop() app.proxy.stop() app.StopEngine() }, Bind: []any{app}, Windows: &windows.Options{ WebviewIsTransparent: false, WindowIsTranslucent: false, // A shop PC is not a developer machine; a stray right-click that // opens devtools looks like the software is broken. DisableWindowIcon: false, }, }) if err != nil { log.Fatalf("behavision-desktop: %v", err) } }