#!/bin/bash
export DISPLAY=:0                       
xrandr --output DSI-1 --rotate left

# 指定输出显示器
OUTPUT="DSI-1"

# 获取 goodix-ts 设备的 ID，确保它是 slave pointer 类型
TOUCHSCREEN_ID=$(xinput list | grep -E 'goodix-ts.*slave.*pointer' | sed -r 's/.*id=([0-9]+).*/\1/')

if [ -z "$TOUCHSCREEN_ID" ]; then
	  echo "Error: goodix-ts not found as a slave pointer."
	    exit 1
fi

# 执行 xinput map-to-output
xinput set-prop "$TOUCHSCREEN_ID" 'Coordinate Transformation Matrix' 0 -1 1 1 0 0 0 0 1  
xinput map-to-output "$TOUCHSCREEN_ID" "$OUTPUT"

echo "Mapped goodix-ts to $OUTPUT with ID $TOUCHSCREEN_ID"