Skip to content
This repository was archived by the owner on Jan 17, 2021. It is now read-only.

Commit b53d00f

Browse files
committed
Add support for chromium
1 parent b6136c5 commit b53d00f

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Chrome is recommended.
1010

1111
```bash
12-
go get go.coder.com/sshcode
12+
GO111MODULE=off go get go.coder.com/sshcode
1313
```
1414

1515
## Usage

main.go

+14-2
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,19 @@ chmod +x ~/bin/code-server
9797
func openBrowser(url string) {
9898
var openCmd *exec.Cmd
9999
if commandExists("google-chrome") {
100-
openCmd = exec.Command("google-chrome", "--app="+url, "--disable-extensions", "--disable-plugins")
100+
openCmd = exec.Command("google-chrome", fmtChromeOptions(url)...)
101+
102+
} else if commandExists("chromium") {
103+
openCmd = exec.Command("chromium", fmtChromeOptions(url)...)
104+
105+
} else if commandExists("chromium-browser") {
106+
openCmd = exec.Command("chromium-browser", fmtChromeOptions(url)...)
107+
101108
} else if commandExists("firefox") {
102109
openCmd = exec.Command("firefox", "--url="+url, "-safe-mode")
110+
103111
} else {
104-
flog.Info("unable to find a browser to open: sshcode only supports firefox and chrome")
112+
flog.Info("unable to find a browser to open: sshcode only supports firefox, chrome, and chromium")
105113

106114
return
107115
}
@@ -112,6 +120,10 @@ func openBrowser(url string) {
112120
}
113121
}
114122

123+
func fmtChromeOptions(url string) []string {
124+
return []string{"--app=" + url, "--disable-extensions", "--disable-plugins"}
125+
}
126+
115127
// Checks if a command exists locally.
116128
func commandExists(name string) bool {
117129
_, err := exec.LookPath(name)

0 commit comments

Comments
 (0)