Take a look at our
ThinkPads.com HOME PAGE
For those who might want to contribute to the blog, start here: Editors Alley Topic
Then contact Bill with a Private Message

[Guide] Setting up Tablet Screen Rotation with Linux

Want to know HOW TO..? Have a FREQUENTLY ASKED QUESTION..?
If you can't find it here, tell us and we'll publish whatever you need
Post Reply

Was this useful?

Yes
6
100%
No
0
No votes
 
Total votes: 6

Message
Author
ATXChris
Posts: 22
Joined: Fri Nov 30, 2012 10:48 pm
Location: Parsippany, NJ

[Guide] Setting up Tablet Screen Rotation with Linux

#1 Post by ATXChris » Fri Feb 15, 2013 9:09 am

Hello ladies and gentlemen, this is my way to help the community back in return for helping me. I hope you find it useful and please leave any comments on what to improve and such!

In this guide you will find how to set up screen rotation on ThinkPad tablet/laptops on a Linux distribution. This is a two part guide; first, we will get auto-rotation working and second, we will bind a 90* counter-clock-wise rotation to a key (usually the rotate key on the face of the tablet).

Part One: Automatic Rotation
A very nice quality-of-life feature of ThinkPad tablets is the automatic screen rotation. When the screen is rotated and folded down, the laptop knows to change the screen orientation... or at least, it should. Now the script below works for Lenovo/IBM, HP, Fujitsu, and Dell tablet hybrids. Below is the link to the LaunchPad webpage for the program:

Magick Rotation

This is a fairly easy to use program, as it has an installer after you extract the .tar.bz file that works on Ubuntu, Fedora, both versions of Linux Mint, and openSUSE. Because it works on Ubuntu, I will venture to say it will run on all (semi) official variants, which are Lubuntu, Xubuntu, Ubuntu Studio, and Kubuntu. However, I only use Xubuntu so I can only confirm it does indeed work on that particular variant. As a note, inside of the .tar.bz, is a file with manual installation instructions, which presumably help you install it on other Linux distributions such as Bodhi Linux.

Here is what the program looks like after it is installed;

Image

As you can see, it is very simple. By default, the rotation state is set to right, but I have mine set to inverted. Also by default, Magick Rotation is told to start on computer start. Finally, by default (underneath Advanced Settings) is the command to show CellWriter when the tablet is rotated and hide when it is unrotated. CellWriter is one on screen keyboard that is available through the Ubuntu Software Center. In my limited use, it works pretty well so far. Obviously you can leave these lines but if you don't have CellWriter installed, you computer may pop a notification of calling a program that doesn't exist. Personally, I like it better than OnBoard that comes default on Xubuntu. Plus, the commands already there, so it's easy.

So that was the easy part, now for something that can prove a bit trickier...

Part Two: 90* CCW Rotation Script
So this simple script is a script that, when used, rotates the screen 90* Counter-Clock-Wise (if ran without swinging the screen) and changes your inputs to act accordingly. So let's get started...

Please Note: Credit for this goes to the Wacom Linux guys over at SourceForge, found here;
Wacom Linux Pages

Step One: Get Input Names
This first step is very important, because without using your models specific names of the TouchPad, Stylus, and TrackPoint, it WILL NOT FUNCTION. So first thing is to open a terminal and run the following command (If you use any external inputs, such as a Wacom Tablet or Mouse, PLUG THEM IN NOW!):

Code: Select all

xinput list
Which will give you a window like this:

Image

Step Two: Make the Script
Now, keep that open and make a new empty file (Right Click > New Document > Empty File) and copy this script into it (again, thank the Wacom Linux guys!);

Code: Select all

#!/bin/sh

# 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 devices.

case "$rotation" in
    normal)
    # rotate to the left
    xrandr -o left
    xsetwacom set stylus rotate ccw
    xsetwacom set eraser rotate ccw
    xsetwacom set touch rotate ccw
    ;;
    left)
    # rotate to inverted
    xrandr -o inverted
    xsetwacom set stylus rotate half
    xsetwacom set eraser rotate half
    xsetwacom set touch rotate half
    ;;
    inverted)
    # rotate to the right
    xrandr -o right
    xsetwacom set stylus rotate cw
    xsetwacom set eraser rotate cw
    xsetwacom set touch rotate cw
    ;;
    right)
    # rotate to normal
    xrandr -o normal
    xsetwacom set stylus rotate none
    xsetwacom set eraser rotate none
    xsetwacom set touch rotate none
    ;;
esac
Now is where you are gonna fly solo for a little bit. Looking at your xinput list, replace 'stylus', 'eraser' and 'touch' with the NAMES (not id=#'s) of your 'Virtual core pointers' (the first half or so of the list). For example, my file looks like this:

Code: Select all

#!/bin/sh

# 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 devices.

case "$rotation" in
    normal)
    # rotate to the left
    xrandr -o left
    xsetwacom set Wacom Tablet stylus rotate ccw
    xsetwacom set Wacom Tablet eraser rotate ccw
    xsetwacom set TPPS/2 IBM TrackPoint rotate ccw
    xsetwacom set USB OPTICAL MOUSE rotate ccw
    ;;
    left)
    # rotate to inverted
    xrandr -o inverted
    xsetwacom set Wacom Tablet stylus rotate half
    xsetwacom set Wacom Tablet eraser rotate half
    xsetwacom set TPPS/2 IBM TrackPoint rotate half
    xsetwacom set USB OPTICAL MOUSE rotate half
    ;;
    inverted)
    # rotate to the right
    xrandr -o right
    xsetwacom set Wacom Tablet stylus rotate cw
    xsetwacom set Wacom Tablet eraser rotate cw
    xsetwacom set TPPS/2 IBM TrackPoint rotate cw
    xsetwacom set USB OPTICAL MOUSE rotate cw
    ;;
    right)
    # rotate to normal
    xrandr -o normal
    xsetwacom set Wacom Tablet stylus rotate none
    xsetwacom set Wacom Tablet eraser rotate none
    xsetwacom set TPPS/2 IBM TrackPoint rotate none
    xsetwacom set USB OPTICAL MOUSE rotate none
    ;;
esac
Note: Make note of something here; I've included in mine, 'USB OPTICAL MOUSE'. This is my cheap wired mouse. It should be on your xinput list if you listened to directions and plugged it in. :P

Step Three: Save and Change Permissions of the Script
Now, save this script to somewhere you can find and access it with sudo (preferably, I haven't tested it in a root location). I put mine in ~/usr/share/ and named it rotate. You do not need to append a file type to the end (i.e no .sh) Open a terminal at this location (either Right Click > Open Terminal Here or open a terminal and use the 'cd' command to get there) and run this command to make it executable;

Code: Select all

sudo chmod +x
And you're good to go, just don't double click on it or your screen will rotate without you. If you do and your screen rotates, and easy way to get back is to keep hitting Enter (because the file is highlighted).

Step Four: Bind the Script
Now to make your keyboard shortcut. Again, this is distribution specific, and may be accomplished with a bit more work from the terminal, but Xubuntu includes a GUI for this. Below is a quick guide for Xubuntu Users, which may help other distributions;

First, go to Settings Manager and find Keyboard

Image

Next, click on the tab that says Application Shortcuts and click Add

Image

Finally, use the little Open button to find your script file.

Image

And then it will ask for a command. Merely press the button you wish to register to the script (In my case, I pushed the button on my screen bezel). All done!



Thanks for reading guys! Please comment with any suggestions or if you would like another guide to setting up something in Xubuntu or Linux in general!stripstrip
IBM ThinkPad X60T
(Core 2 Duo @ 1.5GHz, 2GB RAM, 256GB Toshiba SSD, 12.1" SXGA+ Screen, Xubuntu 12.10)
Guide to Tablet Rotation in Linux
Formerly ATXZerg

matmat
Posts: 3
Joined: Wed Jul 31, 2013 10:33 am
Location: Heidelberg, Germany

Re: [Guide] Setting up Tablet Screen Rotation with Linux

#2 Post by matmat » Wed Jul 31, 2013 11:12 am

Very useful, thank you. Got the manual and screen turning triggered rotation working on my X201T.

Do you see a way to combine this script with the APS readout (so you turn the laptop, and the rotate is triggered)? There seems to be a windows version that can do that (but does not turn the input devices):
forum.thinkpads.com/viewtopic.php?f=27&t=89222

Post Reply
  • Similar Topics
    Replies
    Views
    Last post

Return to “** HOW TOs & FAQs **”

Who is online

Users browsing this forum: No registered users and 1 guest