AutoRotate Daemon
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. But there are no specific reasons why it wouldn’t work on other configurations, so let me know if you have any success.
Features
- 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.
TODO
- GUI for controlling the daemon
- Support other laptops with different accelerometers
- Better documentation
Download Sources
Installation Instructions
Development
You can get the latest sources of autorotate from GitHUB
git clone git://github.com/kkrizka/autorotate.git
Debugging
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.
sudo autorotate.py
“no such device: stylus” Error
Modern 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):
https://help.ubuntu.com/community/X61T#Wacomcpl
Credits
I would like to thank the authors of these pieces of code for demonstrating how to accomplish certain tasks



2 Comments
leave a commentTrackbacks and Pingbacks