mirror of
https://github.com/nkanaev/yarr.git
synced 2025-09-13 09:55:36 +00:00
remove open-golang dependency
This commit is contained in:
@@ -12,7 +12,6 @@ import (
|
||||
"github.com/nkanaev/yarr/src/platform"
|
||||
"github.com/nkanaev/yarr/src/server"
|
||||
"github.com/nkanaev/yarr/src/storage"
|
||||
sdopen "github.com/skratchdot/open-golang/open"
|
||||
)
|
||||
|
||||
var Version string = "0.0"
|
||||
@@ -104,7 +103,7 @@ func main() {
|
||||
|
||||
logger.Printf("starting server at %s", srv.GetAddr())
|
||||
if open {
|
||||
sdopen.Run(srv.GetAddr())
|
||||
platform.Open(srv.GetAddr())
|
||||
}
|
||||
platform.Start(srv)
|
||||
}
|
||||
|
@@ -5,7 +5,6 @@ package platform
|
||||
import (
|
||||
"github.com/getlantern/systray"
|
||||
"github.com/nkanaev/yarr/src/server"
|
||||
"github.com/skratchdot/open-golang/open"
|
||||
)
|
||||
|
||||
func Start(s *server.Handler) {
|
||||
@@ -20,7 +19,7 @@ func Start(s *server.Handler) {
|
||||
for {
|
||||
select {
|
||||
case <-menuOpen.ClickedCh:
|
||||
open.Run(s.GetAddr())
|
||||
Open(s.GetAddr())
|
||||
case <-menuQuit.ClickedCh:
|
||||
systray.Quit()
|
||||
}
|
||||
|
5
src/platform/open.go
Normal file
5
src/platform/open.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package platform
|
||||
|
||||
func Open(input string) error {
|
||||
return open(input).Run()
|
||||
}
|
9
src/platform/open_etc.go
Normal file
9
src/platform/open_etc.go
Normal file
@@ -0,0 +1,9 @@
|
||||
// +build !windows,!darwin
|
||||
|
||||
package platform
|
||||
|
||||
import "os/exec"
|
||||
|
||||
func open(input string) *exec.Cmd {
|
||||
return exec.Command("xdg-open", input)
|
||||
}
|
9
src/platform/open_mac.go
Normal file
9
src/platform/open_mac.go
Normal file
@@ -0,0 +1,9 @@
|
||||
// +build darwin
|
||||
|
||||
package platform
|
||||
|
||||
import "os/exec"
|
||||
|
||||
func open(input string) *exec.Cmd {
|
||||
return exec.Command("open", input)
|
||||
}
|
12
src/platform/open_win.go
Normal file
12
src/platform/open_win.go
Normal file
@@ -0,0 +1,12 @@
|
||||
// +build windows
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func open(input string) *exec.Cmd {
|
||||
rundll32 := filepath.Join(os.Getenv("SYSTEMROOT"), "System32", "rundll32.exe")
|
||||
return exec.Command(rundll32, "url.dll,FileProtocolHandler", input)
|
||||
}
|
Reference in New Issue
Block a user