Created
January 29, 2018 18:13
-
-
Save ericponce/66142ba3f0603513170ee20b5c4b2003 to your computer and use it in GitHub Desktop.
Rotated Tablet Mode script for X1 Yoga (2nd Gen), Good for reading and marking PDFs
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 settings | |
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 | |
# disable TouchPad and TrackPoint | |
xinput disable "TPPS/2 IBM TrackPoint" | |
xinput disable "SynPS/2 Synaptics TouchPad" | |
# enable auto-hide for launcher | |
sleep 0.1 | |
dconf write /org/compiz/profiles/unity/plugins/unityshell/launcher-hide-mode 1 | |
onboard & | |
;; | |
right) | |
# rotate to normal | |
xrandr -o normal | |
xsetwacom set "$stylus" rotate none | |
xsetwacom set "$touch" rotate none | |
xsetwacom set "$eraser" rotate none | |
# enable TouchPad and TrackPoint | |
xinput enable "SynPS/2 Synaptics TouchPad" | |
xinput enable "TPPS/2 IBM TrackPoint" | |
killall onboard | |
# disable auto-hide for launcher | |
sleep 0.1 | |
dconf write /org/compiz/profiles/unity/plugins/unityshell/launcher-hide-mode 0 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment