Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes
2 changes: 0 additions & 2 deletions examples/demo/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates dumb-init chromium \
&& rm -rf /var/lib/apt/lists/*

COPY scripts/wallpaper.jpg /app/wallpaper.jpg

# Copy the pre-built portabledesktop Go binary.
COPY pd/dist/portabledesktop /usr/local/bin/portabledesktop

Expand Down
2 changes: 1 addition & 1 deletion examples/demo/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
const BIN = process.env.PORTABLEDESKTOP_BIN || "portabledesktop";
const VIEWER_HOST = process.env.VIEWER_HOST || "0.0.0.0";
const VIEWER_PORT = normalizePort(process.env.PORT, 5190, "PORT");
const WALLPAPER_PATH = process.env.WALLPAPER_PATH || "/app/wallpaper.jpg";
const WALLPAPER_PATH = process.env.WALLPAPER_PATH || "";
const DEFAULT_PROMPT =
"Play a game of chess in the browser. Explain each move briefly as you play and finish after at least 10 moves.";
const DEFAULT_MODEL = process.env.ANTHROPIC_MODEL || "claude-opus-4-6";
Expand Down
4 changes: 4 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -886,11 +886,15 @@
! -name 'fontconfig' \
! -name 'fonts' \
! -name 'openbox' \
! -name 'portabledesktop' \
! -name 'themes' \
! -name 'xkeyboard-config-2' \
-exec rm -rf {} +
fi

mkdir -p "$runtimePayloadRoot/share/portabledesktop"
cp "${./assets/wallpaper.jpg}" "$runtimePayloadRoot/share/portabledesktop/wallpaper.jpg"

if [ -f "$runtimePayloadRoot/etc/fonts/fonts.conf" ]; then
# Replace build-time /nix/store font dirs with the bundled runtime font dir.
sed -i -E '/<dir>\/nix\/store\/[^<]*<\/dir>/d' "$runtimePayloadRoot/etc/fonts/fonts.conf"
Expand Down
20 changes: 16 additions & 4 deletions pd/internal/desktop/desktop.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,24 @@ func Start(runtimeDir string, opts StartOptions) (*Desktop, error) {
OpenboxPid: openboxPid,
}

// 7. Optional background.
if opts.Background != nil {
if err := d.SetBackground(*opts.Background); err != nil {
return nil, fmt.Errorf("set background: %w", err)
// 7. Background: use caller's choice, or default to the
// runtime wallpaper image, or fall back to a solid color.
if opts.Background == nil {
wallpaper := runtime.ResolveRuntimeData(runtimeDir, "portabledesktop/wallpaper.jpg")
if wallpaper != "" {
opts.Background = &BackgroundOptions{
ImagePath: wallpaper,
Mode: "fill",
}
} else {
opts.Background = &BackgroundOptions{
Color: "#1e1e2e",
}
}
}
if err := d.SetBackground(*opts.Background); err != nil {
return nil, fmt.Errorf("set background: %w", err)
}

return d, nil
}
Expand Down
11 changes: 11 additions & 0 deletions pd/internal/runtime/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,14 @@ func ResolveRuntimeBinary(runtimeDir, name string) string {
}
return name
}

// ResolveRuntimeData returns the full path to a file under
// runtimeDir/share/<subpath> if it exists. Returns an empty
// string if the file is not found.
func ResolveRuntimeData(runtimeDir, subpath string) string {
p := filepath.Join(runtimeDir, "share", subpath)
if _, err := os.Stat(p); err == nil {
return p
}
return ""
}
Loading