summaryrefslogtreecommitdiff
path: root/openBrowser.go
blob: 2977cefbfe2db30efb2f8822ae83ed0955c95ee4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package shell

import (
	"os/exec"
	"runtime"

	"go.wit.com/log"
)

// openBrowser opens the specified URL in the default browser of the user.
func OpenBrowser(url string) error {
	var cmd string
	var args []string

	switch runtime.GOOS {
	case "windows":
		cmd = "cmd"
		args = []string{"/c", "start"}
	case "darwin":
		cmd = "open"
	default: // "linux", "freebsd", "openbsd", "netbsd"
		cmd = "xdg-open"
	}
	args = append(args, url)
	return exec.Command(cmd, args...).Start()
}

func Xterm(cmd string) {
	var tmp []string
	var argsXterm = []string{"nohup", "xterm", "-geometry", "120x40"}
	/*
		if xtermHold.Checked() {
			log.Println("hold = true")
			argsXterm = append(argsXterm, "-hold")
		} else {
			log.Println("hold = false")
		}
	*/
	tmp = append(argsXterm, "-e", cmd)
	log.Info("xterm cmd=", tmp)
	go Run(tmp)
}