-
-
Save pshchelo/c74efae5f2ed73e2952b to your computer and use it in GitHub Desktop.
Using accelerometer to change desktop workspace by tilting the notebook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import time | |
import os | |
with open('/sys/devices/platform/lis3lv02d/position','r') as f: | |
for i in xrange(100): | |
f.seek(0) | |
data = f.read() | |
x, y, z = map(int, data.strip()[1:-1].split(',')) | |
print "{:d}\t{:d}\t{:d}".format(x, y, z) | |
if y > 200: | |
os.system('wmctrl -o 1600,0') | |
elif y < -200: | |
os.system('wmctrl -o 0,0') | |
time.sleep(0.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment