36 lines
635 B
Go
36 lines
635 B
Go
|
|
//go:build !darwin && !notray
|
||
|
|
|
||
|
|
package main
|
||
|
|
|
||
|
|
import (
|
||
|
|
_ "embed"
|
||
|
|
|
||
|
|
"github.com/getlantern/systray"
|
||
|
|
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||
|
|
)
|
||
|
|
|
||
|
|
//go:embed appicon.png
|
||
|
|
var trayIcon []byte
|
||
|
|
|
||
|
|
func (a *App) startTray() {
|
||
|
|
go systray.Run(func() {
|
||
|
|
systray.SetIcon(trayIcon)
|
||
|
|
systray.SetTooltip("waste")
|
||
|
|
|
||
|
|
mShow := systray.AddMenuItem("Open waste", "Show the waste window")
|
||
|
|
systray.AddSeparator()
|
||
|
|
mQuit := systray.AddMenuItem("Quit", "Quit waste")
|
||
|
|
|
||
|
|
for {
|
||
|
|
select {
|
||
|
|
case <-mShow.ClickedCh:
|
||
|
|
runtime.WindowShow(a.ctx)
|
||
|
|
case <-mQuit.ClickedCh:
|
||
|
|
systray.Quit()
|
||
|
|
runtime.Quit(a.ctx)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}, func() {})
|
||
|
|
}
|