commit 8f7baf74869e9eb194413cb0d2ddff5ae35162b5 parent 7c85ea921ef97f32f9ec8590d0b25895babf5dcd Author: dwrz <dwrz@dwrz.net> Date: Fri, 18 Oct 2024 08:43:47 +0000 Add rotate script Diffstat:
A | scripts/rotate | | | 32 | ++++++++++++++++++++++++++++++++ |
1 file changed, 32 insertions(+), 0 deletions(-)
diff --git a/scripts/rotate b/scripts/rotate @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +rotate() { + matrix=$1 + devices=( + 'Wacom Pen and multitouch sensor Finger' + 'Wacom Pen and multitouch sensor Pen Pen (0x80210820)' + 'Wacom Pen and multitouch sensor Pen Eraser (0x80210820)' + ) + + for device in "${devices[@]}"; do + if xinput list | grep -q "$device"; then + xinput set-prop "$device" 'Coordinate Transformation Matrix' "${matrix}" + fi + done +} + +monitor-sensor | while read -r line; do + if [[ $line == *"orientation changed: left-up"* ]]; then + xrandr --output eDP-1 --rotate left + rotate "0 -1 1 1 0 0 0 0 1" + elif [[ $line == *"orientation changed: right-up"* ]]; then + xrandr --output eDP-1 --rotate right + rotate "0 1 0 -1 0 1 0 0 1" + elif [[ $line == *"orientation changed: bottom-up"* ]]; then + xrandr --output eDP-1 --rotate inverted + rotate "-1 0 1 0 -1 1 0 0 1" + elif [[ $line == *"orientation changed: normal"* ]]; then + xrandr --output eDP-1 --rotate normal + rotate "1 0 0 0 1 0 0 0 1" + fi +done