Skip to content

Commit 342285f

Browse files
committed
launch browser automatically at start of desktop
1 parent ba99eae commit 342285f

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

cmd/screen-server/main.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"os/exec"
1111
"regexp"
1212
"strconv"
13+
"strings"
1314
"sync"
1415
"time"
1516

@@ -241,9 +242,12 @@ func runOneScreen(
241242
processes.Start("openbox", func(ctx context.Context) error {
242243
<-xvfbReady
243244

245+
// when window manager starts up, start this program automatically
246+
startupCmd := browserStartupCmd(os.Getenv("START_PAGE"))
247+
244248
// this serves as a window manager so the screen has a menu where the user can start
245249
// Firefox and a terminal
246-
openbox := exec.CommandContext(ctx, "openbox", "--startup", "firefox")
250+
openbox := exec.CommandContext(ctx, "openbox", "--startup", strings.Join(startupCmd, " "))
247251
openbox.Env = append(
248252
os.Environ(), // make sure possible TZ gets passed
249253
"DISPLAY="+screen.XScreenNumberWithColon())
@@ -290,3 +294,13 @@ func parseScreenOpts(serialized string) (*screenOptions, error) {
290294
AttachInputDevice: screenDefParts[5],
291295
}, nil
292296
}
297+
298+
func browserStartupCmd(startPage string) []string {
299+
const browserCmd = "firefox"
300+
301+
if startPage != "" {
302+
return []string{browserCmd, startPage}
303+
} else {
304+
return []string{browserCmd}
305+
}
306+
}

0 commit comments

Comments
 (0)