#!/bin/bash # Start the payload's compositor headless and put an image on its clipboard through chandra-remote. set -euo pipefail p=/payload R=$(mktemp -d /tmp/smXXXX) mkdir "$R/cfg" export XDG_RUNTIME_DIR=$R XDG_CONFIG_HOME=$R/cfg HOME=$R CHANDRA_TEST_CONFIG=1 touch "$R/log" "$R/rem" trap 'rc=$?; [ $rc = 0 ] || cat "$R/log" "$R/rem"; exit $rc' EXIT cd $p/session/usr/local/share/chandra timeout 120 $p/session/usr/local/bin/chandra-host compositor.wasm --socket "$R/wt" \ --theme config/themes/moon-night.json > "$R/log" 2>&1 & for _ in $(seq 200); do [ -S "$R/chandra/wt.sock" ] && break; sleep .2; done ctl() { python3 $p/session/usr/local/bin/chandra-ctl --socket "$R/chandra/wt.sock" "$@"; } ctl ping | grep -qx 'ok pong' ctl list | tail -n 1 printf 'enabled=1\nbind=127.0.0.1\nauth=none\n' > "$R/r.conf" $p/live/usr/local/bin/chandra-remote --config "$R/r.conf" --socket "$R/chandra/wt.sock" \ --shm "$R/fb" --web-dir $p/live/usr/local/share/chandra/remote --bind 127.0.0.1 > "$R/rem" 2>&1 & remote=$! for _ in $(seq 50); do curl -fsS -m 2 -o /dev/null http://127.0.0.1:6080/ 2>/dev/null && break; sleep .2; done python3 -c "import os,sys;sys.stdout.buffer.write(b'\x89PNG\r\n\x1a\n'+os.urandom(1<<20))" > "$R/p.png" out=$(curl -fsS -m 30 -H Expect: -H 'X-Chandra-Remote: 1' -H 'Content-Type: image/png' \ --data-binary "@$R/p.png" http://127.0.0.1:6080/api/clipboard) echo "$out" [ "$out" = '{"ok":true,"serial":1}' ] # It restarts in place, and answers again. kill -USR2 $remote sleep 2 curl -fsS -m 5 http://127.0.0.1:6080/api/clipboard echo echo "smoke ok"