| 1 | #!/bin/sh |
| 2 | # Stand up the parts a Linux login session would have provided, then hand off. |
| 3 | # |
| 4 | # Display :0 is the "host" desktop. The parity engine samples it through |
| 5 | # hostProbe() to measure whether a run disturbed the user's session, and the |
| 6 | # isolated route's claim ("0px, no active-window change") is only worth |
| 7 | # anything if something real is being sampled — a missing :0 would report |
| 8 | # zeroes because the probe failed, not because nothing moved. The isolated |
| 9 | # route's own Xvfb :99 is started by the driver, not here. |
| 10 | set -eu |
| 11 | |
| 12 | HOST_DISPLAY="${CU_HOST_DISPLAY:-:0}" |
| 13 | HOST_GEOMETRY="${CU_HOST_GEOMETRY:-1600x1200x24}" |
| 14 | |
| 15 | Xvfb "$HOST_DISPLAY" -screen 0 "$HOST_GEOMETRY" -nolisten tcp >/tmp/xvfb-host.log 2>&1 & |
| 16 | i=0 |
| 17 | until DISPLAY="$HOST_DISPLAY" xdotool getdisplaygeometry >/dev/null 2>&1; do |
| 18 | i=$((i + 1)) |
| 19 | if [ "$i" -gt 60 ]; then |
| 20 | echo "entrypoint: Xvfb $HOST_DISPLAY did not come up" >&2 |
| 21 | cat /tmp/xvfb-host.log >&2 || true |
| 22 | exit 1 |
| 23 | fi |
| 24 | sleep 0.25 |
| 25 | done |
| 26 | |
| 27 | DISPLAY="$HOST_DISPLAY" openbox >/tmp/openbox-host.log 2>&1 & |
| 28 | sleep 0.5 |
| 29 | |
| 30 | export DISPLAY="$HOST_DISPLAY" |
| 31 | |
| 32 | # AT-SPI rides the session bus, and at-spi-bus-launcher is activated from it on |
| 33 | # demand. Without a session bus every semantic tool fails at the accessibility |
| 34 | # tree, so wrap the whole command rather than starting a daemon and hoping the |
| 35 | # address is inherited. The inner sh also records the session env for |
| 36 | # docker/agent-exec.sh, so `docker exec`'d agents join this same display+bus |
| 37 | # instead of starting blind. |
| 38 | exec dbus-run-session -- sh -c 'printf "DISPLAY=%s\nDBUS_SESSION_BUS_ADDRESS=%s\n" "$DISPLAY" "$DBUS_SESSION_BUS_ADDRESS" > /tmp/cu-session.env; exec "$@"' sh "$@" |
| 39 |