Former-commit-id: bdaf7e0fdd14654d9b4e52046022ad913b26f722 [formerly bdaf7e0fdd14654d9b4e52046022ad913b26f722 [formerly f756feb3848b7a0c89cda655fe1062f6283affd9 [formerly ff41cbf0f19e7e1d254f72e550adc0b506eb743f]]]
Former-commit-id: 03063067ea8bf24017f8d40008d86bc5433edbbf
Former-commit-id: 88eae2fe6a9b139d146de6b0b4916b8f25b70b8c [formerly 22a88b2982e228eb77d7fcea9a9038135b4ce3a7]
Former-commit-id: 4c28a0bceea32e312e2900ba81a3c95dfb9dddd7
pull/15/head
Miguel Mota 6 years ago
parent 00bc3c6565
commit 9474610dd6

@ -2,20 +2,18 @@ package open
import (
"fmt"
"log"
"os/exec"
"strings"
"time"
)
var openCmd string
var possibleCmds = []string{
"xdg-open", // generic linux
"gvfs-open", // gnome linux
"gnome-open", // gnome linux
"kde-open", // kde linux
"exo-open", // xfce linux
"enlightenment_open", // enlightenment linux
"xdg-open", // generic linux
"open", // mac
"start", // windows
"cygstart", // windows
@ -25,19 +23,15 @@ func init() {
for _, cmd := range possibleCmds {
out, err := exec.Command("/bin/bash", "-c", fmt.Sprintf("%s %s %s", "command", "-v", cmd)).Output()
if err != nil {
log.Println("err ", err)
continue
}
log.Println("out ", string(out))
bin := strings.TrimSpace(string(out))
if bin != "" {
openCmd = bin
break
}
}
log.Println("cmd ", openCmd)
time.Sleep(2 * time.Second)
}
// URL open url

Loading…
Cancel
Save