Mon, 14 Aug 2006
hdaps + atspi hotness
I started playing around with the hdaps kernel module on my Thinkpad T43 the other day and wrote some code to utilize some of the accelerometer data. With the help of Juozas and AT-SPI, I wrote a little bit of python that allows you to control your mouse based on your laptops position.
#!/usr/bin/env python
import sys, time, math, atspi
SYSFS_POSITION_FILE = "/sys/devices/platform/hdaps/position"
def main():
theta = 0
rho = 0
ev = atspi.EventGenerator()
while True:
fd = open(SYSFS_POSITION_FILE, 'r')
v = fd.readline().strip()
theta = int(v[1:4])
rho = int(v[5:8])
rads = ((theta - 545)/300.0) * math.pi
ax = math.sin(rads)
rads = ((rho - 475)/300.0) * math.pi
ay = math.sin(rads)
ev.relativeMotion(ax * 10, ay * 10)
fd.close()
time.sleep( 0.01 )
if __name__ == '__main__':
main()
Extremely useless, I know -- but only in it's current state. I'm sure some cool desktop enhancements can be thought up using hdaps. What if you wanted to un-clutter your desktop, so you tilt or laptop to the side and all of your windows slide over to the next virtual desktop? Sounds pretty badass to me.
posted at: 13:50 | link | | 0 comments

