Skip to content

Instantly share code, notes, and snippets.

@eleloya23
Created March 31, 2014 20:09
Show Gist options
  • Save eleloya23/9901109 to your computer and use it in GitHub Desktop.
Save eleloya23/9901109 to your computer and use it in GitHub Desktop.
Rotate Thinkpad Yoga 12.5 on Ubuntu
#!/bin/bash
# Info:
# This is the laptop im talking about: http://shop.lenovo.com/us/en/laptops/thinkpad/yoga-series/yoga
# I'm running Ubuntu 12.04 with Gnome3
#
# The following script toggles the orientation of you screen between NORMAL and INVERTED
# You may bind this script to a key using xbindkeys or gnome-control-center keyboard preferences.
touchscreen='ELAN Touchscreen'
touchpad='SynPS/2 Synaptics TouchPad'
touchpadid=`xinput | grep "$touchpad" | grep -oP '(?<==)[0-9]+\s'`
orientation=`xrandr --properties | grep -oP '(?<=\s)\inverted(?=\s\()'`
#If $orientation is empty, it means it is on normal orientation
function screen_inverted(){
xrandr -o inverted
xinput set-prop "$touchscreen" 'Coordinate Transformation Matrix' -1 0 1 0 -1 1 0 0 1
xinput set-prop $touchpadid 'Device Enabled' 0
onboard &
}
function screen_normal(){
xrandr -o normal
xinput set-prop "$touchscreen" 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1
xinput set-prop $touchpadid 'Device Enabled' 1
killall onboard
}
if [ -z "$orientation" ]; then
# "Screen is in normal orientation"
screen_inverted
else
# "Screen is inverted"
screen_normal
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment