Results 1 to 1 of 1

Thread: HOWTO: Automatic Tablet Screen Rotation, With Manual Control

  1. #1
    Join Date
    May 2006
    Location
    Canada
    Beans
    20
    Distro
    Ubuntu 10.04 Lucid Lynx

    HOWTO: Automatic Tablet Screen Rotation, With Manual Control

    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

    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 full cycle.


    Future Features/Plans:
    • GUI for controlling the daemon
    • Support other laptops with different accelerometers
    • Better documentation


    Installation Instructions for Ubuntu Karmic Koala:

    1. 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.
    2. 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
    3. Update apt-get’s package list:
      Code:
       sudo apt-get update
    4. Install the script and necessary packages:
      Code:
       sudo apt-get install wacom-tools python-xrandr autorotate
    5. 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:
      Code:
       auto-rotate.py&
    6. Restart GDM to start the daemon:
      Code:
       sudo /etc/init.d/gdm restart
    7. 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.

    1. Open the keyboard shorcuts panel, found under System->Preferences->Keyboard Shortcuts.
    2. Click the Add button to create a new custom shortcut.
    3. In the window that pops up, specify
      Name: Rotate Screen
      Command: manual-rotate.py.
    4. Close the window by clicking Apply.
    5. Find the new shortcut at the bottom of the keyboard shortcuts of the window, and map it to a button.
    6. 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:
    Last edited by roadkillbunny; December 22nd, 2009 at 05:05 AM.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •