Skip to content

Instantly share code, notes, and snippets.

@Links2004
Created October 20, 2020 17:32
Show Gist options
  • Save Links2004/551588e503feab457ea86d028b6c1f66 to your computer and use it in GitHub Desktop.
Save Links2004/551588e503feab457ea86d028b6c1f66 to your computer and use it in GitHub Desktop.
ASUS T100HAN Screen / Display + Touch auto rotate
#!/bin/bash
xinput set-prop "SIS0457:00 0457:1133" "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1
xinput set-prop "Asus TouchPad" "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1
while true ; do
xrandrout="$(xrandr)"
x=$(cat /sys/bus/iio/devices/iio\:device0/in_accel_x_raw)
y=$(cat /sys/bus/iio/devices/iio\:device0/in_accel_y_raw)
z=$(cat /sys/bus/iio/devices/iio\:device0/in_accel_z_raw)
rotate=99
if [ $x -le -499000 ] ; then
rotate=3
fi
if [ $x -ge 499000 ] ; then
rotate=1
fi
if [ $rotate = 99 ] ; then
if [ $y -le -499000 ] ; then
rotate=0
fi
if [ $y -ge 499000 ] ; then
rotate=2
fi
fi
if [ $rotate = 99 ] ; then
rotate=1
fi
lrotate=$(echo $xrandrout | grep "left (")
rrotate=$(echo $xrandrout | grep "right (")
irotate=$(echo $xrandrout | grep "inverted (")
if [ "$lrotate" != '' ] ; then
crotate=1
else
if [ "$rrotate" != '' ] ; then
crotate=3
else
if [ "$irotate" != '' ] ; then
crotate=2
else
crotate=0
fi
fi
fi
if [ $crotate != $rotate ] ; then
xrandr -o $(( rotate * 1 ))
case $rotate in
0 ) xinput set-prop "SIS0457:00 0457:1133" "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1;;
1 ) xinput set-prop "SIS0457:00 0457:1133" "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1;;
2 ) xinput set-prop "SIS0457:00 0457:1133" "Coordinate Transformation Matrix" -1 0 1 0 -1 1 0 0 1;;
3 ) xinput set-prop "SIS0457:00 0457:1133" "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1;;
esac
case $rotate in
1 ) xinput set-prop "Asus TouchPad" "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1;;
0 ) xinput set-prop "Asus TouchPad" "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1;;
3 ) xinput set-prop "Asus TouchPad" "Coordinate Transformation Matrix" -1 0 1 0 -1 1 0 0 1;;
2 ) xinput set-prop "Asus TouchPad" "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1;;
esac
fi
sleep 3
done
@Nathan22211
Copy link

ok it seems that when the tablet is flat it likes to go into landscape mode when I want it in portrait. Also, any chance for keyboard detection?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment