Page 1 of 1

X220 Tablet with Linux (Ubuntu) rotation script

Posted: Mon May 28, 2012 7:28 pm
by aeharding
Hi everyone! So, I just installed Ubuntu on my new X220 tablet and I wanted to share a little script that I worked on to make rotation work with the computer, because by default when you rotate the screen orientation the pen, eraser and touch inputs do not rotate as well. So, with this simple script, the screen rotates to the left from default upon clicking it (I'm left-handed; figure it out if you're right-handed) and then back to normal from the left. I did some research in creating the script, but I forgot from where...

Anyways! Put this in a file blah.sh anywhere, and do whatever you want with it! I pinned it to the taskbar thingy in Ubuntu:

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 tools.

case "$rotation" in
    normal)
    # rotate to the left
    xrandr -o left
    xsetwacom set "Wacom ISDv4 E6 Pen stylus" rotate ccw
    xsetwacom set "Wacom ISDv4 E6 Finger touch" rotate ccw
    xsetwacom set "Wacom ISDv4 E6 Pen eraser" rotate ccw
    ;;
    left)
    # rotate to normal
    xrandr -o normal
    xsetwacom set "Wacom ISDv4 E6 Pen stylus" rotate none
    xsetwacom set "Wacom ISDv4 E6 Finger touch" rotate none
    xsetwacom set "Wacom ISDv4 E6 Pen eraser" rotate none
    ;;
esac
Lastly... To pin to the taskbar takes a little skill. Find a icon online that you want (svg works) and follow this guide to pin it to the Unity bar:
http://itshouldbeuseful.wordpress.com/2 ... ntu-11-04/

Good luck! Hope this helped someone... I didn't look to see if something like this had been posted before. If anyone can get it to run when you press the dedicated rotate button, please let me know!

My Unity screenshot: http://lookpic.com/O/i2/956/Zf0xHxN.png
SVG rotate icon: http://www.clker.com/clipart-rotate-ccw-icon.html


EDIT:: Check out this Github installation using this script and some other cool things made by "the undecided":
https://github.com/martin-ueding/think-rotate

Re: X220 Tablet with Linux (Ubuntu) rotation script

Posted: Thu May 31, 2012 8:00 am
by the undecided
I'll try it when I get my X220 Tablet.

It would be good if you specify a license instead of the ambigious “whatever you want”. I assume you refer to the Expat License (a.k.a. MIT License).

Since your full name is in the screenshot, I'd recomment to put a “Copyright © 2012 yourname <youremail>” into the beginning of the script as well. So in case somebody has a question, they know that it is from you.

Re: X220 Tablet with Linux (Ubuntu) rotation script

Posted: Fri Jun 08, 2012 11:45 am
by the undecided
I used your script and enhanced it a little bit. Now you can specify the new orientation as a parameter as well. And I wrote a little manual page for it as well.

The code and everything else is on GitHub

Re: X220 Tablet with Linux (Ubuntu) rotation script

Posted: Fri Jun 08, 2012 8:08 pm
by wolfman
Nice, thanks for sharing that and I like your documentation. Well done.

Re: X220 Tablet with Linux (Ubuntu) rotation script

Posted: Mon Jun 11, 2012 6:27 pm
by aeharding
Glad you like it wolfman. ;)

Thanks "the undecided"! That implementation rocks and is sure to make it easier to find. :)

I am not going to take credit in copyright because I modified it to the Thinkpad x tablet series (specifically my x220) from some long lost source for some older/different brand touchscreen device.

Also... everyone should see this source for adding the script to physical key execution on the 'tablet rotate' button:
http://forum.thinkpads.com/viewtopic.ph ... 10#p676410