A simple package for creating an icon in the system tray and displaying notifications.
To use this package, begin by importing it:
import "github.com/nathan-osman/go-wintray"
Next, create the tray icon:
w := wintray.New()
defer w.Close()
You will likely want to set an icon and tooltip:
//go:embed myapp.ico
var b []byte
w.SetIconFromBytes(b)
w.SetTip("MyApp Is Running")
You can add items to the context menu that is shown when the icon is right-clicked:
w.AddMenuItem("&Print Message", func() {
fmt.Println("This is a tooltip!")
})
Note that the provided function will run on a different goroutine than the caller.
Notifications can be displayed as well:
w.ShowNotification("This is a test.", "Title")