aericktoes

X230 Tablet Autorotation Script

Sep 28th, 2019
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.05 KB | None | 0 0
  1. #!/bin/bash
  2. oldState=0
  3. a='Wacom ISDv4 E6 Pen stylus'
  4. b='Wacom ISDv4 E6 Finger touch'
  5. c='Wacom ISDv4 E6 Pen eraser'
  6.  
  7. while true
  8. do
  9.     state=$(cat /sys/devices/platform/thinkpad_acpi/hotkey_tablet_mode) #This file here is an indicator of whether it's in tablet mode or laptop mode
  10.     if [[ $state == 0 && $oldState == 1 ]]
  11.     then
  12.         xrandr -o normal
  13.         #xsetwacom --set "$a" Rotate none #Not needed on GNOME and some other DEs
  14.         #xsetwacom --set "$b" Rotate none #Not needed on GNOME and some other DEs
  15.         #xsetwacom --set "$c" Rotate none #Not needed on GNOME and some other DEs
  16.         oldState=0
  17.     elif [[ $state == 1 && $oldState == 0 ]]
  18.     then
  19.         xrandr -o inverted
  20.         #xsetwacom --set "$a" Rotate half #Not needed on GNOME and some other DEs
  21.         #xsetwacom --set "$b" Rotate half #Not needed on GNOME and some other DEs
  22.         #xsetwacom --set "$c" Rotate half #Not needed on GNOME and some other DEs
  23.         ~/.backlight 0 #Script to turn off keyboard backlight
  24.         oldState=1
  25.     fi
  26.     sleep 3s
  27. done
Advertisement
Add Comment
Please, Sign In to add comment