After receiving a Lenovo Yoga 13 for Christmas, I have been pleased with its performance with Ubuntu. It is easy to change the display orientation under the Display settings menu or by typing, e.g. xrandr -o inverted in the terminal. However, such does not rotate the input of the touchscreen (or—less importantly—the touchpad).

I have looked around for solutions to this issue, and found two promising sources.
(1) http://cc.oulu.fi/~rantalai/synaptics/. Installing the package here and running the advised commands rotated the display and touchpad input (but not that of the touchscreen).
(2) http://www.elfsternberg.com/2013/05/25/thinkpad-yoga-ubuntu-12/. This website recommended updating an input package, which I haven't tried.

  • The Problem (and solution) is the same on the Yoga 2 Pro
    – rubo77
    Jun 20, 2014 at 7:58
  • Maybe you can add auto-rotation with this script too: krizka.net/projects/autorotate
    – rubo77
    Jun 20, 2014 at 11:30

5 Answers 5


I found a straightforward answer to my question by reading the helpful information at Ubuntu Wiki: X - Input Coordinate Transformation.

These commands can be used to align rotations of the input devices and the display:

  1. The first command rotates the display, where can be left, right, normal, or inverted:
    xrandr -o <orientation>

  2. remap the input device:
    xinput set-prop '<device name>' 'Coordinate Transformation Matrix' <matrix-elements-rowwise>

The second command remaps the input device (that is, the touchpad or the the touchscreen) where <matrix-elements-rowwise> is 0 -1 1 1 0 0 0 0 1, 0 1 0 -1 0 1 0 0 1, 1 0 0 0 1 0 0 0 1, or -1 0 1 0 -1 1 0 0 1; corresponding to the orientations above.

The names of the touchpad and touchscreen can be found with xinput list and either can be disabled entirely with xinput disable <device-name>. Subsequently, xinput enable <device-name> will re-enable the input device.

In my case, and probably for others with a Yoga 13 (also on Yoga 2 Pro), the touchscreen is called ELAN Touchscreen and the touchpad SynPS/2 Synaptics TouchPad.

Thus, I put a short script in my home directory called rotate-inverted.sh with the following content:

    # This script rotates the screen and touchscreen input 180 degrees, disables the touchpad, and enables the virtual keyboard
    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'
    onboard &

Then I made the script executable with

chmod u+x rotate-inverted.sh

and assigned the command ~/rotate-inverted.sh to the keyboard shortcut Ctrl+Alt+I in
System Settings -> Keyboard.

After I logged out and logged back in, I was able to rotate the keyboard by pressing that shortcut.

I did the same type of thing for the other rotation positions, using the commands xinput enable 'SynPS/2 TouchPad' and killall onboard instead of xinput disable 'SynPS/2 TouchPad' and onboard & for rotate-normal.sh.

Some others on this thread have discussed assigning such scripts to the extra buttons on the
Yoga — such as the lock button — as well as automatically executing them upon changing the Yoga's position; but I was not sure how to do this.

  • Thanks for your detailed work. I was wondering if you had come across any research that talked about how to get this reorientation to happen immediately (using the accelerometer, I'm guessing)?
    – A.Wan
    Jan 30, 2014 at 4:46
  • This also works perfect on my Yoga 2 Pro! The enhanced script below by user267578 works perfect! I will add it on my Guide to install Ubuntu on Lenovo Yoga 2 Pro
    – rubo77
    Jun 19, 2014 at 22:17
  • Maybe you find out How to use the correct Key to map your script on here?
    – rubo77
    Jun 19, 2014 at 22:23

I added couple more lines, second run of the script will turn screen back to normal and enable the touchpad, tested with Ideapad 2 Pro. By the way I did put launcher for the script on the side panel HowTo: new launcher.

Accelerometer is not yet supported in the kernel, but maybe something is coming on next release.

create the script /usr/local/bin/rotate-screen.sh

# 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

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

if [ $isEnabled == 1 ] 
    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 &
    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 

and give it executable rights:

sudo chmod +x /usr/local/bin/rotate-screen.sh

The utility spin is designed to work with the ThinkPad Yogas, so it handles stylus information and so on, and it offers all sorts of orientation control (by button, screen rotation and accelerometer). It may be worth trying.


A solutions without xrandr (which doesn't work on wayland)

A solution on Ubuntu 19.04 with wayland is to set the rotate-monitor key to some keybinding using gsettings or dconf-editor.

For instance, the following command will cause Ctrl+F8 to rotate the screen counterclockwise:

$ gsettings set org.gnome.mutter.keybindings rotate-monitor "['XF86RotateWindows', '<Control>F8']"

This does not allow the user to specify the target orientation, but only to rotate the screen until the desired orientation is reached.

(original posted here: https://unix.stackexchange.com/a/465395/20661)


autorotate is Linux/X11 utility for 2in1 laptops and other devices with touchscreen. No ROOT privileges necessary!

Command left right portrait and lanscape are wrappers around xrandr and xinput to synchronize rotation of screen and digitizer. In fact they will rotate all xinput devices including stylus, touchpad, touchscreen, mouse...

Laptops with axis sensor can be run without any command to detect orientation. Flag --daemon is designed to run in background as a service.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .