aboutsummaryrefslogtreecommitdiff
path: root/.scripts/rotate
diff options
context:
space:
mode:
Diffstat (limited to '.scripts/rotate')
-rwxr-xr-x.scripts/rotate42
1 files changed, 42 insertions, 0 deletions
diff --git a/.scripts/rotate b/.scripts/rotate
new file mode 100755
index 0000000..97b045a
--- /dev/null
+++ b/.scripts/rotate
@@ -0,0 +1,42 @@
+#!/usr/bin/env bash
+
+nibble="TPPS/2 IBM TrackPoint"
+stylus="Wacom ISDv4 90 Pen stylus"
+eraser="Wacom ISDv4 90 Pen eraser"
+
+matrix="$(xinput list-props "$stylus" | awk '/Coordinate Transformation Matrix/{print $5$6$7$8$9$10$11$12$NF}')"
+
+# Matrix declarations
+
+normal="1 0 0 0 1 0 0 0 1"
+normal_float="1.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,1.000000"
+
+inverted="-1 0 1 0 -1 1 0 0 1"
+inverted_float="-1.000000,0.000000,1.000000,0.000000,-1.000000,1.000000,0.000000,0.000000,1.000000"
+
+left="0 -1 1 1 0 0 0 0 1"
+left_float="0.000000,-1.000000,1.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000"
+
+right="0 1 0 -1 0 1 0 0 1"
+
+if [ "$matrix" == $normal_float ] && [ "$1" != "-n" ]; then
+ xrandr -o inverted
+ xinput set-prop "$stylus" 166 $inverted
+ xinput set-prop ""$eraser"" 166 $inverted
+ xinput set-prop ""$nibble"" 166 $inverted
+elif [ "$matrix" == $inverted_float ] && [ "$1" != "-j" ] && [ "$1" != "-n" ]; then
+ xrandr -o left
+ xinput set-prop "$stylus" 166 $left
+ xinput set-prop "$eraser" 166 $left
+ xinput set-prop "$nibble" 166 $left
+elif [ "$matrix" == $left_float ] && [ "$1" != "-j" ] && [ "$1" != "-n" ]; then
+ xrandr -o right
+ xinput set-prop "$stylus" 166 $right
+ xinput set-prop "$eraser" 166 $right
+ xinput set-prop "$nibble" 166 $right
+else
+ xrandr -o normal
+ xinput set-prop "$stylus" 166 $normal
+ xinput set-prop "$eraser" 166 $normal
+ xinput set-prop "$nibble" 166 $normal
+fi