-
-
Save wonbinbk/92e6177ebb21220ec8291c733bd844e8 to your computer and use it in GitHub Desktop.
Script to monitor iio-sensor-proxy output and rotate the Thinkpad X1 Yoga display/touch mask/stylus mask based on that info.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
monitor-sensor --accel | while read line | |
orientation="normal" | |
rotate="none" | |
do | |
if [[ $line =~ .*right.* ]]; then | |
orientation="right" | |
rotate="cw" | |
elif [[ $line =~ .*left.* ]]; then | |
orientation="left" | |
rotate="ccw" | |
elif [[ $line =~ .*bottom.* ]]; then | |
orientation="inverted" | |
rotate="half" | |
elif [[ $line =~ .*normal.* ]]; then | |
orientation="normal" | |
rotate="none" | |
fi | |
# device Id 9 is the Touch screen | |
xsetwacom --set 9 Rotate ${rotate} | |
# devie Id 10 is the Stylus | |
xsetwacom --set 10 Rotate ${rotate} | |
# then the frame itself | |
xrandr -o ${orientation} | |
# better sleep a bit to not clog the CPU just for this | |
# Would be nice to actually poll for changes in the sensor device | |
sleep 3 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment