Wednesday, June 16, 2010

A Tablet...

We have already got a tablet and we need no more tablet!

So I've been running Ubuntu 9.04 on my laptop since pretty much the beginning. When 9.10 Karmic Koala was released I almost upgraded, but then I realized I was very near to the end of a semester and what a dumb idea that would be. Especially since I use my laptop for nigh on everything.

But recently I stumbled (or re-stumbled, as the case may be) upon a blog that has some great posts about the x61. It would seem he's got pretty much the same laptop as I have - I'm mainly led to believe this by the fact that he has no touch screen either.

Using this post, I finally got the HDAPS working, back when I was running Ubuntu 9.04.

But now that I'm in between semesters (starting up this Thursday), I upgraded to 9.10 (mainly because Krizka posted about his experience being fairly straightforward). Of course it messed with all my custom tweaks with the tablet rotation, so I had to fix that. Using Krizka's autorotate project I pretty much had no trouble. After getting my hdaps module working again, the autorotate worked perfectly - something I had never been able to accomplish previously. The only problem is that with my previous script when the tablet display was folded down I liked the screen to be inverted - I found that was the best for my use in school. So looking through some of the documentation and inspiration that Krizka posted/provided, and using some of the tools I came up with this result:

I created a python script called "rotate" (you could name it .py if you wanted, but I didn't) and inserted the following:


import sys
import dbus
import pynotify
from traceback import print_exc

from libautorotate import *

D = DIRECTIONS = {'normal':1, 'left':2, 'right':8, 'inverted':4}

def main():

rotate = AutoRotate()
current = rotate.GetRotation()

if len(sys.argv) > 1:
next = DIRECTIONS[sys.argv[1]]
except KeyError:
print sys.argv[1], 'is not a valid direction!'




sudo cp rotate /usr/local/bin/
sudo chmod 555 /usr/local/bin/rotate

After that, I created a file:

sudo vi /etc/acpi/events/swivel-down

into which I put the following (taken from here)

# Called when the tablet screen swivels down
event=ibm/hotkey HKEY 00000080 00005009
action=/usr/local/bin/rotate inverted

And now I have the best of both worlds. When I flip my screen down, it auto rotates to the orientation I like best (and I also have the ability to launch some extra programs if I need (though I think I may have to re-modify the wacomcpl script to automatically launch the config dialog... whoops, forgot to save that customization!)

So, this is really a big "Thank you!" to Karol Krizka

No comments: