A python script that rotates the orientation of a tablet computer running Linux based on the physical orientation of the screen. It works by repeatedly reading the current orientation of tablet from a built in hard drive accelerometer, and rotating the screen if orientation exceeds a minimum treshhold. There is a 2 second pause between checking the orientation, in order to conserve battery life and allow the user to momentary change the orientation without having the screen rotated.
There are two main scripts that come with the package:
- auto-rotate.py – Daemon that runs in the background and periodically checks the orientation of the tablet
- manual-rotate.py – Script that when called, controls the running daemon. Also can be used without the daemon, in which case it just rotates a screen to the next rotation.
Note: This script was only tested with a ThinkPad X61T and Ubuntu Karmic and Lucid. But there are no specific reasons why it wouldn’t work on other configurations, so let me know if you have any success.
- Automatic screen rotation based on the physics orientation when in tablet mode (read via hdaps module)
- Changing from laptop mode into tablet mode automatically rotates the screen 180 degrees, even if the tablet is in a horizontal orientation
- Fixes orientation of the mouse buttons and wacom stylus
- Minimum treshhold for change of rotation so small deviations won’t change the screen
- Can be controlled via dbus
- Control script (manual-rotate.py) that can disable automatic rotation and rotate the screen 90 degrees. Returns to automatic rotation after doing a 360 degree cycle.
- GUI for controlling the daemon (using indicator menus?)
- Support other laptops with different accelerometers
- Better documentation
You can get the latest sources of autorotate from GitHUB
git clone git://github.com/kkrizka/autorotate.git
It is possible that you run into some problems, especially if you are missing some dependencies or have other problems. You can get error messages by running the script manually using the following command. Note that you do need to run it with sudo, because the wacom tools need root privileges.
“no such device: stylus” Error
Relatively older versions of X.Org use HAL to determine what input devices are connected to the computer. And HAL, by default gives weird names to wacom devices, so wacomctl can’t find them. You need to rename them following these instructions (should work outside of Ubuntu too):
This only needs to be done for AutoRotate 0.4 running on Ubuntu Karmic Koala or older. Ubuntu Lucid Lynx no longer uses HAL.
I would like to thank the authors of these pieces of code for demonstrating how to accomplish certain tasks