Skip to content

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:

  • – Daemon that runs in the background and periodically checks the orientation of the tablet
  • – 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 ( 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

Download Sources

Installation Instructions


You can get the latest sources of autorotate from GitHUB

git clone 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

Related Software


Leave a comment
  1. nick / Dec 19 2010

    Hello, I’m hoping you can help me with some strange behavior.

    I’m running Ubuntu 10.10, and I installed your software from the 10.04 ppa you’ve provided. If I execute “sudo” from a console, everything goes swimmingly; I can put the x61t in to tablet mode and spin it around all day, your script keeps up with it. Yet any attempt I’ve made to add ‘’ to the startup sequence causes erratic behavior.

    For starters, when i first flip the screen and put it in tablet mode, rather than orienting towards me, as it does when executed from a terminal, it orients the screen 90 degrees clockwise. Then as i begin flipping the laptop around, every position causes a different, and wrong, screen orientation. The only orientation which is correct is the initial one which occurs when i first place my laptop in to tablet mode. Unfortunately, the tablet is upside down in this position, with the fan facing down, and the tablet buttons upside-down.

    I’ve tried placing ‘ &’ in both a startup script which executes when my session starts, and in the /etc/gdm/Init/Default file which your guide suggests. Both yield the same result. Do you know what about the startup sequence could be breaking the script?

    Best Regards

    • Karol Krizka / Dec 26 2010

      That is indeed interesting. I do not know what the difference between the using the start-up sequence and launching manually could be. I’ll investigate.

      • nick / Dec 27 2010


        I spent days and days playing with this. I knew no python, so i learned it and rewrote some of to help me debug the problem. The solution ended up being rather simple (of course). There seems to be a ‘bug’ of sorts in the hdaps module itself, where ‘/sys/devices/platform/hdaps/calibrate’ isn’t populated with anything useful until ‘/sys/devices/platform/hdaps/orientation’ is polled. Namely, typing: ‘cat /sys/devices/platform/hdaps/calibrate’ on startup will simply return: (0,0). However, if you type ‘cat /sys/devices/platform/hdaps/orientation’ before polling the calibration file (as does), then the calibration file will return appropriate values.

        Unfortunately, I can’t verify whether or not the original file will behave accordingly on startup, because I reworked the majority of the run(self) function. I’d be happy to email / post my changes if anyone is interested; but I’m guessing that the original ‘s dependence on the calibration file was causing the abnormal rotations to begin with—so ensuring the contents of ‘/sys/devices/platform/hdaps/orientation’ should fix it up (if you’re experiencing the same bug as me).

        That’s about it, thanks for the beautiful script! Now I can stop relying on those nasty acpid scripts which limit me to two orientations.

        Best Regards

  2. x.trapnel / Apr 5 2011

    I was thinking a bit about design and layout recently, and suddenly wondered: xrandr doesn’t do anything about changing subpixel font smoothing, does it? How would one add that capability to the script?

  3. x.trapnel / Apr 5 2011

    (ie, as it rotates, the subpixel smoothing should go from RGB to V-BGR to BGR to V-RGB.)

  4. Andrew Perrin / Apr 29 2011

    Hi – trying to get this working on my new Lenovo X201 tablet running debian testing. The first issue (minor) was that I had to make sure hdaps was installed:

    apt-get install hdapsd

    now auto-rotate engages correctly and the screen rotates, but the tablet input isn’t rotated along with it, so the pen location doesn’t match the point on the screen when it’s rotated. Looking at, it looks like it’s just calling xsetwacom (right?), which is available on the system (/usr/bin/xsetwacom). I’m happy to do some debugging work on it but not sure where to start.

    Thanks for your help-
    Andy Perrin

    • Karol Krizka / May 1 2011

      I think I know what might be causing it. When I updated my laptop to Ubuntu Natty, I had the same problem and it turned out that they changed the formatting of xsetwacom slightly, so my script wouldn’t get the list of wacom device and hence couldn’t rotate its coordinates.

      I’ve fixed it in the git repository, which you can checkout from:
      It is still beta software, but I don’t think it has any major bugs. Just some unfinished new features (an indicator applet for Ubuntu).

      • Andrew Perrin / May 2 2011

        Thank you for your response! However, while that problem may be fixed, the git version I just checked out (2011-05-02, 3:00 pm ET) has a new problem:

        Traceback (most recent call last):
        File “/usr/local/bin/”, line 24, in
        from librotate import AutoRotateDaemon
        File “/usr/local/lib/python2.6/dist-packages/librotate/”, line 34, in
        from . import Rotate
        File “/usr/local/lib/python2.6/dist-packages/librotate/”, line 29, in
        class Rotate:
        File “/usr/local/lib/python2.6/dist-packages/librotate/”, line 30, in Rotate
        AttributeError: ‘module’ object has no attribute ‘get_current_screen’

        This problem does not exist using 0.4.1, which runs fine, but doesn’t rotate the tablet along with the screen.

        One other tidbit: this message appears on the console when rotating under 0.4.1:

        Cannot find device ‘Serial Wacom Tablet eraser id: 14 type:’.
        Cannot find device ‘Serial Wacom Tablet stylus id: 15 type:’.
        Cannot find device ‘Serial Wacom Tablet eraser id: 14 type:’.
        Cannot find device ‘Serial Wacom Tablet stylus id: 15 type:’.

        Thanks again.

      • Andrew Perrin / May 2 2011

        I just figured out the problem with xsetwacom not rotating correctly in my case. It has to do with how xsetwacom reports devices in the –list output. The following minor patch to 0.4.1 fixes it:

        root@simmel:/usr/src/autorotate-0.4.1# diff
        > dev_type=parts.pop();
        > dev_type=parts.pop();
        > dev_type=parts.pop();

Trackbacks and Pingbacks

  1. ThinkPad X61 Tablet Automatic Screen Rotation Under Linux | Karol Krizka
  2. AutoRotate 0.4 – The not-allowed-to-own-the-service-“net.krizka.autorotate”-due-to-security-policies Release | Karol Krizka
Leave a comment