Plan section 6 step 1. A Cargo workspace of its own under spikes/gpui (own lock, not a member of the root workspace, so the root's lock, deny policy, notices and CI are untouched; it builds into the checkout's target/), on gpui-kit pinned to =0.8.0. No gpui-kit release builds on Rust 1.94 (every gpui-pre 0.3.x calls std::hint::cold_path, stable since 1.95), so the workspace says rust-version 1.95. - shell.sh: the toolchain (1.95.0, 1.94, stable or nightly, all from one pinned fenix), the native libraries, Mesa's lavapipe as the only Vulkan driver, Xvfb, openbox and the X tools, Noto Color Emoji and Noto Sans CJK. - headless.sh: a private Xvfb display with openbox and a private session bus, never the desktop's; headless-wayland.sh: sway's headless backend. - spike-common: CPU by thread group and memory from /proc once a second with the spike's counters (meter), proc-meter and damage-count for programs without a meter (the Slint app), Inter and the emoji/CJK fonts, the client's Lucide icons as GPUI assets, and the BGRA twin of voelin_media::convert::to_rgba. From the interrupted 2026-10-25 attempt, kept; changed here: shell.sh takes 1.94 and nightly from the pinned fenix (the store paths it named were garbage-collected), the README's headless-wayland.sh paragraph (sway, not weston), its fmt command (-p, not --all), its toolchain and nixpkgs lines, and the font docs (GPUI drops Noto Color Emoji from a fallback chain). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
69 lines
2.9 KiB
Bash
Executable File
69 lines
2.9 KiB
Bash
Executable File
#!/bin/sh
|
|
# Run a command on a private headless Wayland compositor: sway on wlroots'
|
|
# headless backend (it has a seat, which GPUI's Wayland backend requires and
|
|
# weston's headless backend lacks), its socket in its own XDG_RUNTIME_DIR,
|
|
# and a private D-Bus session bus, so nothing reaches the desktop the
|
|
# command is started from. No X display is set (no XWayland).
|
|
#
|
|
# spikes/gpui/headless-wayland.sh [-r pixman|gles2|vulkan] [-s WIDTHxHEIGHT] -- COMMAND...
|
|
#
|
|
# -r: the compositor's renderer (default pixman, the CPU; gles2 or vulkan
|
|
# use the GPU of a render node); -s: the output size (default 3840x2160).
|
|
# Run it inside shell.sh; keys go in with wtype (virtual keyboard). State
|
|
# lives in $SPIKE_STATE as for headless.sh.
|
|
set -eu
|
|
renderer=pixman size=3840x2160
|
|
while [ $# -gt 0 ]; do
|
|
case $1 in
|
|
-r) renderer=$2; shift 2 ;;
|
|
-s) size=$2; shift 2 ;;
|
|
--) shift; break ;;
|
|
*) break ;;
|
|
esac
|
|
done
|
|
[ $# -gt 0 ] || { echo "headless-wayland.sh: no command" >&2; exit 2; }
|
|
root=$(cd "$(dirname "$0")/../.." && pwd)
|
|
SPIKE_STATE=${SPIKE_STATE:-$root/.scratch/gpui-spikes-state}
|
|
# Short: a socket path has at most 107 bytes (sway's IPC socket is
|
|
# sway-ipc.<uid>.<pid>.sock in it).
|
|
runtime=$root/.scratch/wl
|
|
mkdir -p "$runtime" "$SPIKE_STATE/config" "$SPIKE_STATE/data" "$SPIKE_STATE/cache"
|
|
chmod 700 "$runtime"
|
|
tools=$(nix build --option substituters "https://cache.nixos.org/ https://nix-community.cachix.org" \
|
|
--no-link --print-out-paths nixpkgs#sway nixpkgs#wtype)
|
|
for t in $tools; do PATH="$t/bin:$PATH"; done
|
|
unset DISPLAY WAYLAND_DISPLAY WAYLAND_SOCKET XDG_SESSION_TYPE DBUS_SESSION_BUS_ADDRESS SWAYSOCK
|
|
export XDG_RUNTIME_DIR="$runtime" XDG_CONFIG_HOME="$SPIKE_STATE/config"
|
|
export XDG_DATA_HOME="$SPIKE_STATE/data" XDG_CACHE_HOME="$SPIKE_STATE/cache"
|
|
cat >"$SPIKE_STATE/sway.conf" <<CONF
|
|
output HEADLESS-1 resolution $size position 0 0
|
|
default_border none
|
|
focus_follows_mouse no
|
|
CONF
|
|
WLR_BACKENDS=headless WLR_LIBINPUT_NO_DEVICES=1 WLR_RENDERER=$renderer \
|
|
sway --unsupported-gpu -c "$SPIKE_STATE/sway.conf" >"$SPIKE_STATE/sway.log" 2>&1 &
|
|
compositor=$!
|
|
trap 'kill $compositor 2>/dev/null; wait $compositor 2>/dev/null || true' EXIT INT TERM
|
|
i=0
|
|
until socket=$(ls "$runtime" 2>/dev/null | grep '^wayland-[0-9]*$' | head -1) && [ -n "$socket" ]; do
|
|
i=$((i + 1))
|
|
[ $i -lt 100 ] || { echo "sway did not start" >&2; cat "$SPIKE_STATE/sway.log" >&2; exit 1; }
|
|
sleep 0.1
|
|
done
|
|
export WAYLAND_DISPLAY=$socket
|
|
cat >"$SPIKE_STATE/dbus-session-wayland.conf" <<CONF
|
|
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
|
|
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
|
<busconfig>
|
|
<type>session</type>
|
|
<listen>unix:path=$runtime/bus</listen>
|
|
<auth>EXTERNAL</auth>
|
|
<policy context="default">
|
|
<allow send_destination="*" eavesdrop="true"/>
|
|
<allow eavesdrop="true"/>
|
|
<allow own="*"/>
|
|
</policy>
|
|
</busconfig>
|
|
CONF
|
|
dbus-run-session --config-file="$SPIKE_STATE/dbus-session-wayland.conf" -- "$@"
|