mirror of
https://github.com/nkanaev/yarr.git
synced 2025-05-24 21:19:19 +00:00
34 lines
588 B
Go
34 lines
588 B
Go
// +build macos windows
|
|
|
|
package platform
|
|
|
|
import (
|
|
"github.com/getlantern/systray"
|
|
"github.com/nkanaev/yarr/server"
|
|
"github.com/skratchdot/open-golang/open"
|
|
)
|
|
|
|
func Start(s *server.Handler) {
|
|
systrayOnReady := func() {
|
|
systray.SetIcon(Icon)
|
|
|
|
menuOpen := systray.AddMenuItem("Open", "")
|
|
systray.AddSeparator()
|
|
menuQuit := systray.AddMenuItem("Quit", "")
|
|
|
|
go func() {
|
|
for {
|
|
select {
|
|
case <-menuOpen.ClickedCh:
|
|
open.Run("http://" + s.Addr)
|
|
case <-menuQuit.ClickedCh:
|
|
systray.Quit()
|
|
}
|
|
}
|
|
}()
|
|
|
|
s.Start()
|
|
}
|
|
systray.Run(systrayOnReady, nil)
|
|
}
|