remove open-golang dependency

This commit is contained in:
Nazar Kanaev
2021-03-01 15:37:06 +00:00
parent 93eeef0131
commit 5b0b47635d
8 changed files with 37 additions and 7 deletions

View File

@@ -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
View File

@@ -0,0 +1,5 @@
package platform
func Open(input string) error {
return open(input).Run()
}

9
src/platform/open_etc.go Normal file
View 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
View 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
View 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)
}