2022-02-22 21:13:08 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# 2022-02-22, Nico Schottelius
|
|
|
|
# Inspired by https://gist.github.com/Links2004/5976ce97a14dabf773c3ff98d03c0f61
|
|
|
|
|
|
|
|
output=$(xrandr | awk '/connected primary/ { print $1 }')
|
2022-08-09 12:04:01 +00:00
|
|
|
#input=$(xinput --list | grep -e "Pen" | sed 's/.*id=\([0-9]*\).*/\1/')
|
|
|
|
input_1="Wacom HID 5276 Finger"
|
|
|
|
input_2="Wacom HID 5276 Pen Pen (0x81266661)"
|
2022-02-22 21:13:08 +00:00
|
|
|
|
|
|
|
monitor-sensor | (
|
|
|
|
while true; do
|
|
|
|
read line
|
|
|
|
ORIENTATION=$(echo $line | awk -F: '/Accelerometer orientation changed:/ { print $2 } ' | sed 's/ *//')
|
|
|
|
|
|
|
|
# Check if we are matching on a correct line, if not, skip
|
|
|
|
if [ -z "$ORIENTATION" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo $ORIENTATION
|
|
|
|
|
|
|
|
case "$ORIENTATION" in
|
|
|
|
normal)
|
|
|
|
rotate="normal"
|
|
|
|
matrix="1 0 0 0 1 0 0 0 1"
|
|
|
|
;;
|
|
|
|
bottom-up)
|
|
|
|
rotate="inverted"
|
|
|
|
matrix="-1 0 1 0 -1 1 0 0 1"
|
|
|
|
;;
|
|
|
|
right-up)
|
|
|
|
rotate="right"
|
|
|
|
matrix="0 1 0 -1 0 1 0 0 1"
|
|
|
|
;;
|
|
|
|
left-up)
|
|
|
|
rotate="left"
|
|
|
|
matrix="0 -1 1 1 0 0 0 0 1"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# set -x
|
|
|
|
xrandr --output ${output} --rotate ${rotate}
|
2022-08-09 12:04:01 +00:00
|
|
|
xinput set-prop "${input_1}" 'Coordinate Transformation Matrix' ${matrix}
|
|
|
|
xinput set-prop "${input_2}" 'Coordinate Transformation Matrix' ${matrix}
|
2022-02-22 21:13:08 +00:00
|
|
|
# set +x
|
|
|
|
done
|
|
|
|
)
|