Tuesday, June 21, 2011

Rotate tablet PC screen with a single button in Ubuntu 11.04

Someone asked me for help on tablet screen rotation in Ubuntu for an older (2006) Lenovo X60 tablet PC - in particular, the desire was to make it as simple as possible to flip the screen 180 degrees since on this model, for right-handers, a flipped screen is more comfortable ergonomically for....tableting. Simplicity suggested a big noticeable blue button on the Unity 11.04 Launcher (the slide out bar on the left). Being new to Unity myself, there were a couple of quirks to figure out.

My goal was to add a button to the launcher that would fire off a shell script. The script relies on xrandr (for screen rotation) and xsetwacom (for the stylus to map correctly to the rotated screen). They're easy to use after some manpage-skimming and they don't require elevated privileges.


Now, how to add it to the Unity launcher bar? Either you can create a .desktop file from scratch or you can use the menu option for creating a launcher, and repurpose the .desktop to point to your script. Here's the one I used, which also points to a serviceable picture of a generic monitor icon, courtesy of Gnome.

After dragging it to the launcher and a re-login, the button does the intended trick.

And here are a couple of useful links to ubuntuforums.org posts that told me everything I needed to know to rush out the above tidbits.

No comments:

Post a Comment