Я нахожусь в конце этого остроумия, и я уверен, что это легко. У меня есть следующий скрипт bash, который работает для вращения ввода выводов на моем Surface Pro 3 под управлением Ubuntu 18.04. Мне просто нужно запускать его вручную каждый раз, когда я поворачиваю устройство:
#!/bin/sh
# Find the line in "xrandr -q --verbose" output that contains current screen orientation and "strip" out current orientation.
rotation="$(xrandr -q --verbose | grep 'connected' | egrep -o '\) (normal|left|inverted|right) \(' | egrep -o '(normal|left|inverted|right)')"
# Using current screen orientation proceed to rotate screen and input tools.
# echo "$rotation"
case "$rotation" in
normal)
xinput set-prop "NTRG0001:01 1B96:1B05 Pen Pen (0)" --type=float "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1
;;
left)
# -rotate to normal
# xinput set-prop "NTRG0001:01 1B96:1B05 Pen Pen (0)" --type=float "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1
xinput set-prop "NTRG0001:01 1B96:1B05 Pen Pen (0)" --type=float "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1
;;
esac
Однако этот, который использует монитор-датчик, чтобы попытаться определить, когда устройство поворачивается и автоматически меняет преобразование пера, не делает, и Я не могу понять, почему:
#!/bin/sh
# Set the pen coordinates when the screen rotates
pen_device='NTRG0001:01 1B96:1B05 Pen Pen (0)'
ctm='Coordinate Transformation Matrix'
monitor-sensor \
| grep --line-buffered "Accelerometer orientation changed" \
| grep --line-buffered -o ": .*" \
| while read -r line; do
line="${line#??}"
echo "Rotation: $line"
if [ "$line" = "normal" ]; then
xinput set-prop "$pen_device" --type=float "$ctm" 1 0 0 0 1 0 0 0 1
elif [ "$line" = "left-up" ]; then
xinput set-prop "$pen_device" --type=float "$ctm" 0 -1 1 1 0 0 0 0 1
elif [ "$line" = "right-up" ]; then
xinput set-prop "$pen_device" --type=float "$ctm" 0 1 0 -1 0 1 0 0 1
elif [ "$line" = "bottom-up" ]; then
xinput set-prop "$pen_device" --type=float "$ctm" -1 0 1 0 -1 1 0 0 1
else
echo "Unknown rotation: $line"
continue
fi
done