summaryrefslogtreecommitdiff
path: root/ar/.local/bin/tablet
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-01-24 20:35:27 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-01-24 20:35:27 +0900
commitc80a54e42b52ce297f0f2f71af23c562832025c7 (patch)
treedcce8bb977a770f473325d48f6f70b21d9818a40 /ar/.local/bin/tablet
init
Diffstat (limited to 'ar/.local/bin/tablet')
-rwxr-xr-xar/.local/bin/tablet39
1 files changed, 39 insertions, 0 deletions
diff --git a/ar/.local/bin/tablet b/ar/.local/bin/tablet
new file mode 100755
index 0000000..1b4e556
--- /dev/null
+++ b/ar/.local/bin/tablet
@@ -0,0 +1,39 @@
+#!/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' | grep -Eo '\) (normal|left|inverted|right) \(' | grep -Eo '(normal|left|inverted|right)')"
+penstylus="$(xsetwacom list devices | grep 'Pen' | grep 'stylus' | sed 's/\s*id.*//g')"
+penerase="$(xsetwacom list devices | grep 'Pen' | grep 'erase' | sed 's/\s*id.*//g')"
+fingertouch="$(xsetwacom list devices | grep 'Finger' | grep 'touch' | sed 's/\s*id.*//g')"
+
+# Using current screen orientation proceed to rotate screen and input tools.
+case "$rotation" in
+normal)
+ # rotate to the left
+ xrandr -o left
+ xsetwacom set "$penstylus" rotate ccw
+ xsetwacom set "$penerase" rotate ccw
+ xsetwacom set "$fingertouch" rotate ccw
+ ;;
+left)
+ # rotate to normal
+ xrandr -o inverted
+ xsetwacom set "$penstylus" rotate half
+ xsetwacom set "$penerase" rotate half
+ xsetwacom set "$fingertouch" rotate half
+ ;;
+inverted)
+ # rotate to normal
+ xrandr -o right
+ xsetwacom set "$penstylus" rotate cw
+ xsetwacom set "$penerase" rotate cw
+ xsetwacom set "$fingertouch" rotate cw
+ ;;
+right)
+ # rotate to normal
+ xrandr -o normal
+ xsetwacom set "$penstylus" rotate none
+ xsetwacom set "$penerase" rotate none
+ xsetwacom set "$fingertouch" rotate none
+ ;;
+esac