mirror of
https://github.com/nkanaev/yarr.git
synced 2025-09-13 18:00:05 +00:00
gui-less mode for linux
This commit is contained in:
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()
|
||||
}
|
Reference in New Issue
Block a user