Anyway, here is the program:
#Detect taps via AMSTracker in order to change
#spaces. Based on the Perl script by Erling Ellingsen (http://blog.medallia.com/2006/05/smacbook_pro.html)
#
#by Sean Brewer (http://seabre986.googlepages.com)
#Note:
#AMSTracker MAY NOT BE DISTRIBUTED WITH THIS PROGRAM.
#The author of AMSTracker does not allow distribution (without his permission anyway)
#so, in order to use this script you must download AMSTracker from:
# http://www.osxbook.com/software/sms/amstracker/
#If anyone actually reads this PLEASE PLEASE PLEASE someone
#come up with a free software alternative to this! If I have time I'll do it!
#License:
#This program is licensed under the GPL.
#See http://www.gnu.org/licenses/gpl.txt for more details.
#Instructions: It's simple really.
#1. Download AMSTracker and put this program and AMSTracker into the
# same directory.
#2. Run this program. If you don't know how, ask a friend.
#3. Tap the side of your screen to change spaces.
from os import waitpid
from subprocess import Popen,PIPE
from signal import SIGTERM
amscheck = Popen (["./AMSTracker","-s","-u0.01"], stdout=PIPE)
stable = 0
#Hopefully you have at least one space, right?
space = 1
#This is the maximum number of spaces
#on my mac, though yours may be more or less, so
#change this accordingly.
space_max = 4
#The actual script to change spaces.
def spaces_script(num):
return """osascript -e 'tell application "System Events"
tell process "Finder"
keystroke\"""" + str(num) + """\" using control down
end tell
end tell'"""
while 1:
i = amscheck.stdout.readline().split()
if len(i) > 3:
continue
i = map(lambda j: int(j),i)
#We get a signed short written as two unsigned bytes.
if i[0] < 0:
i[0] += 256
x = (i[1] * 256) + i[0]
if abs(x) < 20:
stable += 1
if abs(x) > 30 and stable > 30:
stable = 0
#The logic here allows for movement
#to the next specified (by the tap) space.
if x < 0 and space == 1:
space += 1
elif x < 0 and space == space_max:
space -= 1
elif x < 0:
space -= 1
else:
space += 1
#I really need to make this cleaner.
p = Popen (spaces_script(space), shell=True)
sts = waitpid(p.pid,0)
It's really simple to run. All you need to do is download the script: here
and then download the program to get the sensor data: here
Put both programs into the same directory, and then run smack.py, then test it out. It should work.