Skip to content

Commit da95f49

Browse files
committed
Fix open on linux
1 parent 6983212 commit da95f49

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

browser_linux.go

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
package browser
22

33
import (
4+
"os"
45
"os/exec"
56
)
67

78
func openBrowser(url string) error {
8-
sensibleBrowser, err := exec.LookPath("sensible-browser")
9-
if err != nil {
10-
// sensible-browser not availble, try xdg-open
11-
return exec.Command("xdg-open", url).Run()
9+
// try sensible-browser first
10+
if err := runCmd("sensible-browser", url); err == nil {
11+
return nil
1212
}
13-
return exec.Command(sensibleBrowser, url).Run()
13+
// sensible-browser not availble, try xdg-open
14+
return runCmd("xdg-open", url)
15+
}
16+
17+
func runCmd(prog string, args ...string) error {
18+
cmd := exec.Command(prog, args...)
19+
cmd.Stdout = os.Stdout
20+
cmd.Stderr = os.Stderr
21+
return cmd.Run()
1422
}

0 commit comments

Comments
 (0)