AtlatestRepositorysigil-wm
1
#!/usr/bin/env bash2
set -euo pipefail3
cd "$(dirname "$0")/.."4
make -j2 all build/x11-client build/readback5
runtime_dir=$(mktemp -d /tmp/sigil-wm-x11.XXXXXX)6
export XDG_RUNTIME_DIR=$runtime_dir7
export WLR_BACKENDS=headless WLR_RENDERER=pixman WLR_HEADLESS_OUTPUTS=18
export SIGIL_WM_REPL="$runtime_dir/repl"9
server_pid= managed_pid= menu_pid=10
cleanup() {11
for child in "$menu_pid" "$managed_pid" "$server_pid"; do12
[[ -z $child ]] || kill "$child" 2>/dev/null || true13
[[ -z $child ]] || wait "$child" 2>/dev/null || true14
done15
rm -rf "$runtime_dir"16
}17
trap cleanup EXIT18
wait_log() {19
for ((attempt=0; attempt<300; attempt++)); do20
if grep -q "$2" "$1"; then return; fi21
sleep 0.0522
done23
cat "$1" >&224
return 125
}26
wait_value() {27
for ((attempt=0; attempt<100; attempt++)); do28
if bash scripts/msg "$SIGIL_WM_REPL" "$1" | grep -q '(value #t)'; then return; fi29
sleep 0.130
done31
cat build/receipts/x11.log >&232
return 133
}34
timeout 90 bash scripts/run-sigil -L src eval -f test/x11.sgl > build/receipts/x11.log 2>&1 &35
server_pid=$!36
wait_log build/receipts/x11.log '^X_DISPLAY=:'37
export DISPLAY38
DISPLAY=$(sed -n 's/^X_DISPLAY=//p' build/receipts/x11.log | head -1)39
timeout 80 build/x11-client normal > build/receipts/x11-managed.log 2>&1 &40
managed_pid=$!41
wait_value '(and managed #t)'42
wait_log build/receipts/x11-managed.log '^X11_FOCUS=1'43
wait_value '(and saw-client-move? saw-client-resize?)'44
timeout 80 build/x11-client override > build/receipts/x11-menu.log 2>&1 &45
menu_pid=$!46
wait_value '(and managed menu #t)'47
sleep 0.348
bash scripts/msg "$SIGIL_WM_REPL" '(host-snapshot host)' > build/receipts/x11-snapshot49
bash scripts/msg "$SIGIL_WM_REPL" '(begin (emulate-key! host 1 30 #t) (emulate-key! host 1 30 #f))'50
wait_log build/receipts/x11-managed.log '^X11_KEY=38,0'51
bash scripts/msg "$SIGIL_WM_REPL" "(capture-output! host output-id \"$PWD/build/receipts/x11.ppm\")"52
for ((attempt=0; attempt<200; attempt++)); do53
[[ ! -s build/receipts/x11.ppm ]] || break54
sleep 0.0555
done56
sleep 0.257
build/readback build/receipts/x11.ppm build/receipts/x11.png x1158
bash scripts/msg "$SIGIL_WM_REPL" '(close-window! host menu)'59
wait "$menu_pid"60
menu_pid=61
wait_value '(not menu)'62
bash scripts/msg "$SIGIL_WM_REPL" '(close-window! host managed)'63
wait "$managed_pid"64
managed_pid=65
wait_value '(null? windows)'66
bash scripts/msg "$SIGIL_WM_REPL" '(stop-host! host)'67
wait "$server_pid"68
server_pid=69
grep -q '^X11_HOST=PASS' build/receipts/x11.log70
if grep -q 'event handler failed' build/receipts/x11.log; then cat build/receipts/x11.log >&2; exit 1; fi71
echo 'X11=PASS managed override input explicit-placement capture teardown'