i3/.config/i3/rotate.sh

27 lines
584 B
Bash
Executable File

#!/bin/bash
ids=$(xinput --list|grep "SAM\|Digitizer"|grep -oP "id=\K[\w]*")
#ids=( 9 10 11 )
transform_matrix=""
rotate=$1
case $rotate in
0) #normal
transform_matrix="1 0 0 0 1 0 0 0 1";;
1) #left
transform_matrix="0 -1 1 1 0 0 0 0 1";;
2) #inverted
transform_matrix="-1 0 1 0 -1 1 0 0 1";;
3) #right
transform_matrix="0 1 0 -1 0 1 0 0 1";;
esac
for input in ${ids[@]}; do
echo xinput set-prop $input "Coordinate Transformation Matrix" $transform_matrix
xinput set-prop $input "Coordinate Transformation Matrix" $transform_matrix
done
xrandr -o $rotate