Skip to content

Instantly share code, notes, and snippets.

@dw5
Last active December 30, 2017 16:50
Show Gist options
  • Save dw5/59c6c7d08584ab9d16e58c83d4298225 to your computer and use it in GitHub Desktop.
Save dw5/59c6c7d08584ab9d16e58c83d4298225 to your computer and use it in GitHub Desktop.
linux tablet touch fix when rotated
#!/bin/bash
# This script rotates the screen and touchscreen input 180 degrees, disables the touchpad, and enables the virtual keyboard
# And rotates screen back if the touchpad was disabled
# experimental / source: https://www.reddit.com/r/linux4noobs/comments/539fw5/how_would_i_rotate_the_touch_screen_in_linux/
# to get device list "xinput list"
isEnabled=$(xinput --list-props 'SynPS/2 Synaptics TouchPad' | awk '/Device Enabled/{print $NF}')
if [ $isEnabled == 1 ]
then
echo "Screen is turned upside down"
xrandr -o inverted
xinput set-prop 'ELAN Touchscreen' 'Coordinate Transformation Matrix' -1 0 1 0 -1 1 0 0 1
xinput disable 'SynPS/2 Synaptics TouchPad'
# Remove hashtag below if you want pop-up the virtual keyboard
# onboard &
else
echo "Screen is turned back to normal"
xrandr -o normal
xinput set-prop 'ELAN Touchscreen' 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1
xinput enable 'SynPS/2 Synaptics TouchPad'
# killall onboard
fi
@dw5
Copy link
Author

dw5 commented Dec 30, 2017

#!/bin/bash
# This script rotates the screen and touchscreen input 180 degrees, disables the touchpad, and enables the virtual keyboard
# And rotates screen back if the touchpad was disabled

# experimental / source: https://www.reddit.com/r/linux4noobs/comments/539fw5/how_would_i_rotate_the_touch_screen_in_linux/
# to get device list "xinput list"

isEnabled=$(xinput --list-props 'SynPS/2 Synaptics TouchPad' | awk '/Device Enabled/{print $NF}')

# replace with "if file exist" maybe...
if [ $isEnabled == 1 ] 
then
    echo "Screen is turned upside down"
    xrandr -o inverted
    xinput set-prop 'ELAN Touchscreen' 'Coordinate Transformation Matrix' -1 0 1 0 -1 1 0 0 1
    xinput disable 'SynPS/2 Synaptics TouchPad'
    # Remove hashtag below if you want pop-up the virtual keyboard  
    # onboard &
else
    echo "Screen is turned back to normal"
    xrandr -o normal
    xinput set-prop 'ELAN Touchscreen' 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1
    xinput enable 'SynPS/2 Synaptics TouchPad'
    # killall onboard 
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment