#!/data/data/com.termux/files/usr/bin/bash
# Pixel 6 屏幕读取工具
# 用法: bash pixel6-screen-reader.sh [screenshot|ui|ocr]

ACTION=${1:-screenshot}
OUTPUT_DIR=~/.openclaw/workspace/data

case $ACTION in
  screenshot)
    # 截图
    screencap -p $OUTPUT_DIR/screen-latest.png
    echo "Screenshot saved to $OUTPUT_DIR/screen-latest.png"
    ;;
  
  ui)
    # 读取界面元素
    uiautomator dump $OUTPUT_DIR/ui-latest.xml 2>&1
    cat $OUTPUT_DIR/ui-latest.xml
    ;;
  
  ocr)
    # 截图 + 保存（需要外部 OCR 工具）
    screencap -p $OUTPUT_DIR/screen-for-ocr.png
    echo "Screenshot saved for OCR: $OUTPUT_DIR/screen-for-ocr.png"
    ;;
  
  *)
    echo "Usage: $0 [screenshot|ui|ocr]"
    exit 1
    ;;
esac
