Created
April 14, 2016 11:26
-
-
Save sarmbruster/a3a6f4f62ccdc074af7b4e349e6d9bf0 to your computer and use it in GitHub Desktop.
script for Thinkpad X1 Yoga to rotate screen and input devices
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/sh | |
# screen and input device rotation for e.g. a Thinkpad X1 Yoga | |
# adopted from by the script from http://ubuntuforums.org/showthread.php?t=996830&p=6274392#post6274392 | |
# | |
# Usage: | |
# ./rotate.sh | |
# will rotate both the screen and input device either to right or normal setting depending on previous state. Additionally: | |
# * in "right" layout, a on screen keyboard (onboard) is started or stopped in normal mode | |
# * the touchpad is switched off in "right" mode | |
# | |
# I've bound this script to a shortcut key for easily flipping back and forth settins | |
stylus=`xsetwacom --list devices | grep " stylus" | cut -f 1` | |
eraser=`xsetwacom --list devices | grep " eraser" | cut -f 1` | |
touch=`xsetwacom --list devices | grep " touch" | cut -f 1` | |
# Find the line in "xrandr -q --verbose" output that contains current screen orientation and "strip" out current orientation. | |
rotation="$(xrandr -q --verbose | grep 'connected' | egrep -o '\) (normal|left|inverted|right) \(' | egrep -o '(normal|left|inverted|right)')" | |
# Using current screen orientation proceed to rotate screen and input tools. | |
case "$rotation" in | |
normal) | |
# rotate to the right | |
xrandr -o right | |
xsetwacom set "$stylus" rotate cw | |
xsetwacom set "$touch" rotate cw | |
xsetwacom set "$eraser" rotate cw | |
xinput set-prop 12 "Device Enabled" 0 # touchpad off | |
onboard & | |
;; | |
right) | |
# rotate to normal | |
xrandr -o normal | |
xsetwacom set "$stylus" rotate none | |
xsetwacom set "$touch" rotate none | |
xsetwacom set "$eraser" rotate none | |
xinput set-prop 12 "Device Enabled" 1 # touchpad on | |
killall onboard | |
;; | |
esac |
Thank you :-). The touchpad had also 13 on my system and 12 is the physical keyboard.
xinput set-prop 13 "Device Enabled" 0 # touchpad off
xinput set-prop 12 "Device Enabled" 0 # touchpad off
My laptop is Lenovo ThinkPad X1 Yoga 20FQ-002U.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you! The touchpad had ID 13 on my system. xinput accepts names in addition to ids, so I changed the line to