#!/usr/bin/env bash # 无头截图取证:装 → 启(可带启动参数)→ 截图 → 修正方向。 # # 本环境没有 GUI,模拟器帧缓冲恒为竖屏;带 -txLandscape 1 时 app 会经 # requestGeometryUpdate 把「内容」转成横屏(设计基准 iPad Pro 13″ 1366×1024), # 但帧缓冲仍是竖的,故截完用 sips 转回来,Read 出来才是设计稿的方向。 # # 用法: # scripts/tx-shot.sh /tmp/shot.png # 只截当前画面 # scripts/tx-shot.sh /tmp/shot.png -- -txUIFixture 1 -txLandscape 1 # 重启并带参数 set -euo pipefail UDID="${TX_UDID:-2EA9055E-4557-4B20-82AF-56A68AC1D454}" BUNDLE=ai.athom.terminalx OUT="${1:?usage: tx-shot.sh [-- ]}" shift || true if [ "${1:-}" = "--" ]; then shift APP=$(find ~/Library/Developer/Xcode/DerivedData/TerminalX-*/Build/Products/Debug-iphonesimulator \ -maxdepth 1 -name TerminalX.app | head -1) [ -n "$APP" ] || { echo "TerminalX.app not found — build first" >&2; exit 1; } xcrun simctl terminate "$UDID" "$BUNDLE" 2>/dev/null || true xcrun simctl install "$UDID" "$APP" xcrun simctl launch "$UDID" "$BUNDLE" --args "$@" >/dev/null # 等 surface attach + OutputGate flush(tmux/多 pane 场景需要更久) sleep "${TX_SETTLE:-6}" LANDSCAPE=0 for a in "$@"; do [ "$a" = "-txLandscape" ] && LANDSCAPE=1; done else LANDSCAPE="${TX_LANDSCAPE:-1}" fi xcrun simctl io "$UDID" screenshot "$OUT" >/dev/null 2>&1 if [ "$LANDSCAPE" = "1" ]; then sips -r 90 "$OUT" >/dev/null # landscapeRight 内容 → 正向 fi sips -g pixelWidth -g pixelHeight "$OUT" | tail -2 echo "wrote $OUT"