-
-
Save Migacz85/3f544933ce5add438555ba7cd33f0413 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
#This script will automaticly rotate your screen and change correctly touches from the screen. | |
#Before running the script: | |
#go to https://github.com/hadess/iio-sensor-proxy and and follow all steps to install the code. | |
#find your TOUCHPAD, and TRANSFORM, variables. You can find them using | |
#typing in terminal: | |
#xinput list | |
#tested on hp x360 13s-s150sa, manjaro kde | |
#in case when you dont want install iio-sensor-proxy you can use this script: | |
#https://gist.github.com/tuxflo/5b400c86a5ebde871d94c6bff94ad6cb | |
#but screen will only rotate once is executed. | |
#Update this according to output form command: xinput list | |
TOUCHPAD="ELAN Touchscreen" | |
TRANSFORM='Coordinate Transformation Matrix' | |
monitor-sensor | while read line | |
do | |
if [[ $line =~ .*left.* ]] | |
then | |
xrandr -o left | xinput set-prop "$TOUCHPAD" "$TRANSFORM" 0 -1 1 1 0 0 0 0 1 | |
fi | |
if [[ $line =~ .*right.* ]] | |
then | |
xrandr -o right | xinput set-prop "$TOUCHPAD" "$TRANSFORM" 0 1 0 -1 0 1 0 0 1 | |
fi | |
if [[ $line =~ .*bottom-up.* ]] | |
then | |
xrandr -o inverted | xinput set-prop "$TOUCHPAD" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1 | |
fi | |
if [[ $line =~ .*normal.* ]] | |
then | |
xrandr -o normal | xinput set-prop "$TOUCHPAD" "$TRANSFORM" 1 0 0 0 1 0 0 0 1 | |
fi | |
Works great, thanks
Also struggling with this issue on my Thinkpad X1 Yoga Gen1.
So instead of using xinput, I use xsetwacom --set 9 Rotate ccw
to rotate the Touch mask CCW, and xsetwacom --set 10 Rotate ccw
to rotate the Stylus touch mask CCW.
If I understand this correctly, this script will keep calling monitor-sensor
but we might not want that, maybe a 1 second sleep in between the read is fine for quick reaction. Or maybe we can create a systemd service that depends on iio-sensor-proxy service to run this script.
Just put a modified version of this script on https://gist.github.com/wonbinbk/92e6177ebb21220ec8291c733bd844e8
for those who use Thinkpad X1 Yoga on Manjaro like myself. Works nicely but the way xrandr turn off the screen while rotating is not as smooth as how it works on Fedora.
On my system (Fedora 31, bash v5.0.11(1), I needed to complete the do section. Line 38: done
It now works well. Thank you.