gui-less mode for linux
This commit is contained in:
parent
9de14fcb09
commit
439d98003f
4 changed files with 52 additions and 26 deletions
33
platform/gui.go
Normal file
33
platform/gui.go
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
// +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(server.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)
|
||||
}
|
||||
11
platform/guiless.go
Normal file
11
platform/guiless.go
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// +build !windows,!macos
|
||||
|
||||
package platform
|
||||
|
||||
import (
|
||||
"github.com/nkanaev/yarr/server"
|
||||
)
|
||||
|
||||
func Start(s *server.Handler) {
|
||||
s.Start()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue