I've written a python daemon that checks the orientation of a tablet pc from a built in accelerometer (currently hdaps based ones only supported), and then it rotates the screen such that it fits the physical orientation.
I think it has an advantage over some of the other scripts out there in that my daemon exposes a dbus interface that can be used to control it. For example, I wrote another script that connect to the running daemon to disable automatic rotation and switches to manual rotation. I mapped one of the buttons by the screen to it.
This is my first program that I've released, so initially it might have some problems/bad design decisions because I've only tested it on my ThinkPad X61T running Ubuntu Karmic. So I'm open to suggestions and criticism.
You can find more details about the project here: AutoRotate
- 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 full cycle.
- GUI for controlling the daemon
- Support other laptops with different accelerometers
- Better documentation
Installation Instructions for Ubuntu Karmic Koala:
- Make sure you have a working accelerometer that is reading the proper orientation. For ThinkPad X61T, you have to compile the tp-smapi-source kernel module manually.
- Add my ThinkPadX61T PPA repository by appending the following line to the end of the /etc/apt/sources.list file:
Code:deb http://ppa.launchpad.net/kkrizka/thinkpad-x61t/ubuntu karmic main
- Update apt-get’s package list:
Code:sudo apt-get update
- Install the script and necessary packages:
Code:sudo apt-get install wacom-tools python-xrandr autorotate
- To have auto-rotate.py autostart on GDM. This way it will be available to all users, even during login. This is done by adding the following line to the end of the /etc/gdm/Init/Default file before the exit 0 command:
- Restart GDM to start the daemon:
Code:sudo /etc/init.d/gdm restart
- Swivel down your screen into the tablet mode, and tilt it at around 45 degrees to test if the script works!
The following are instructions for using the control script. I should note that this script also works without a daemon running, in which case it just rotates the screen to the next rotation. With the daemon running, it disables the daemon and rotates the screen 90 degrees. After it does a full cycle, it re-enables the daemon.
- Open the keyboard shorcuts panel, found under System->Preferences->Keyboard Shortcuts.
- Click the Add button to create a new custom shortcut.
- In the window that pops up, specify
Name: Rotate Screen
- Close the window by clicking Apply.
- Find the new shortcut at the bottom of the keyboard shortcuts of the window, and map it to a button.
- Close the keyboard shortcuts window, go into tablet mode and press the button that you mapped in the previous step to the manual-rotate.py script.
I would also give some credit to the authors of the following scripts, because their work taught me how to accomplish certain tasks: