@@ -97,11 +97,19 @@ chmod +x ~/bin/code-server
97
97
func openBrowser (url string ) {
98
98
var openCmd * exec.Cmd
99
99
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
+
101
108
} else if commandExists ("firefox" ) {
102
109
openCmd = exec .Command ("firefox" , "--url=" + url , "-safe-mode" )
110
+
103
111
} 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 " )
105
113
106
114
return
107
115
}
@@ -112,6 +120,10 @@ func openBrowser(url string) {
112
120
}
113
121
}
114
122
123
+ func fmtChromeOptions (url string ) []string {
124
+ return []string {"--app=" + url , "--disable-extensions" , "--disable-plugins" }
125
+ }
126
+
115
127
// Checks if a command exists locally.
116
128
func commandExists (name string ) bool {
117
129
_ , err := exec .LookPath (name )
@@ -124,7 +136,6 @@ func scanAvailablePort() (string, error) {
124
136
l , err := net .Listen ("tcp" , fmt .Sprintf (":%d" , port ))
125
137
if err != nil {
126
138
// If we have an error the port is taken.
127
- port ++
128
139
continue
129
140
}
130
141
_ = l .Close ()
0 commit comments