// SPDX-License-Identifier: AGPL-3.0-or-later package main import ( "context" _ "embed" "log/slog" "github.com/wailsapp/wails/v3/pkg/application" ) //go:embed build/appicon.png var trayIcon []byte // newTray adds the system tray icon: click to bring the window back, and a // menu to check for updates or quit. func newTray(app *application.App, win *application.WebviewWindow, updates bool) *application.SystemTray { menu := app.NewMenu() menu.Add("Open Docwell").OnClick(func(*application.Context) { showWindow(win) }) if updates { menu.Add("Check for updates…").OnClick(func(*application.Context) { go func() { // Shows the updater's own window when a release is found. if err := app.Updater.CheckAndInstall(context.Background()); err != nil { slog.Warn("update check failed", "err", err) } }() }) } menu.AddSeparator() menu.Add("Quit Docwell").OnClick(func(*application.Context) { app.Quit() }) tray := app.SystemTray.New() tray.SetIcon(trayIcon) tray.SetTooltip("Docwell") tray.SetMenu(menu) tray.OnClick(func() { showWindow(win) }) return tray } func showWindow(win *application.WebviewWindow) { win.Show() win.UnMinimise() win.Focus() }