Thursday, November 15, 2007

Smack your Leopard Spaces

Updated 14/03/08:
The file link is updated. Previous link has the file extension of .pl which caused problem for many people. I am sorry.

I came across Brian Jepson's blog today and made some changes to make it work for Leopard Spaces.

All you need:

1. smackleopard.command

Download here(14/03/2008 Updated Link)

2. AMSTracker
Amit Singh's site:

Put AMSTracker in same directory as smackleopard.command.

Open Terminal

Change permisson on smackleopard.command:

To change the script's permission so that it becomes excutable, you'll need to type the following under Terminal:

chmod +x smackleopard.command

You can find Terminal under Applications->Utilities

If you could not successfully run this:
chmod +x smackleopard.command

please make sure you have the privilege to chmod. Try 'su' first to become a superuser (your password will be asked) or use sudo chomod instead.

(Updated on 4th Dec)

Run it. (./smackleopard.command)


I'll put up a clip on YouTube soon.



Anonymous said...

Hey there. if you could email me at that would be amazing. i have no idea how to change the permission thing i have everything else already done.



Thomas said...

Please upload it to a filesharing service that actually works...

Anonymous said...

Hey, How are you? Im New to apple and i really dont know how to change a permission using terminal. if you can please help me with some instructions i would really appreciate it. Thanks. My email is

Robin said...

hi, thanks for all this, but i don't manage to change the permission thing like the others
can you email me at : please, thanks

Jason Shen said...

Hi mates above.

Haven't been here for a while, sorry.

The post itself is updated. Hope that helps.

I didn't know that Skydrive killed my 2KB script file:( shame on MS.


August said...

hey, i really want this to work. nice work though by the way. can someone email me at

Juanchooo said...

ok if someone could please guide me on how to do this i have tried and google info on this but no luck, a step by step guide would be great. im sorry im a newbie just bought my first macbook and i had been using wondows since 95. please help i am clueless on Terminal and perl and commands and all that, a step by step guide like you were teaching a baby who doesnt know ANYTHING about Macs


my email es

David Gibson said...

I managed to run the script, but upon its activation "spaces" just begins to randomly switch from space to space. The laptop is motionless, and on a level surface.

Is it possible the AMSTracker is too sensitive/not operating correctly?

I have an Intel Macbook. Is there a difference in sensors between the standard Macbook and the Macbook Pro?

Thanks so much in advance if you're able to help!!

-David Gibson

Jason Shen said...

Hi august, juanchoo
You may want to check out the updated post above.

Hi David,
You can try run the AMSTracker itself to see what's going on:

./amstracker -u 1

For more sensitivity details please refer to:


Antonio said...
This comment has been removed by the author.
Antonio said...

How can I disable this script?

It turns out it's not for me. :(

Idar said...

Hi, I it won't work...
chmod +x smackleopard.command is it exactly what I should writ in Terminal? Keeps getting the answer: chmod: smackleopard.command: No such file or directory..

Unknown said...

I'm getting the same problem as "Idar". It keeps saying "no such directory"
when I use sudo chomod +x smackbook.leopard

Please help or email:

Any help would be GREATLY appreciated!! Thanks!!

David Gibson said...

Are you sure you're in the same directory as smackleopard.command? You need to navigate to the directory you extracted AMSTracker and smackleopard.command to.

Itamar Broderson said...

i did everything right but this shows up:

here this is the terminal error:
Last login: Tue Dec 11 17:22:11 on ttys000
You have mail.
Macintosh-3:~ itamarbroderson$ chmod +x smackleopard.command
Macintosh-3:~ itamarbroderson$ su
sh-3.2# ./smackleopard.command
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LC_ALL = (unset),
LANG = "UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
AMS hardware present and initialized

thank you

Andrew said...

What do you mean by navigate? I have both of the files in the same directory, but do I need to "navigate" somehow with terminal?

Thanks again.

Jason Shen said...

Sorry guys. I really don't have time to reply all the comments and emails.

If you find yourself not being able to run chmod, just check you put everything in the same folder and your are currently in that folder (using Terminal) before typing that command.

Also, use 'su' before chmod...

I'll still keep an eye on this post and will try to reply you guys in time.


David Gibson said...

Sorry if this is too basic, but when I say navigate I mean make sure you've "cd"ed to the directory you have the two files in.

Also, as much as I hate to be a buzzkill, I kinda gave up on getting this working. The sensitivity control was really erratic on my macbook, and using control-arrow to change spaces is much faster and less damaging (parking and unparking drive heads constantly can't be great for the HD's longevity). I know the smacking thing is cool, but I dunno if its worth the trouble just to show people.

Andrew said...

"cd"ed??? Sorry I've never used terminal before so I have no idea what you're talking about....

Thanks again!

David Gibson said...

When you execute a program in terminal, you need to be in the same folder as the program.

For instance, in OSX, you would open your applications folder in finder, then double click the program you wished to run. The same principle must be adhered to in terminal. When you open terminal, it starts in ~, which is the home directory for the user you've logged in as. To get to applications you must type "cd /Applications", where "cd" is the command to change directories and "/Applications" is the absolute path of the directory you'd like to go to.

If you put AMSTracker and smackleopard.command in a folder called "Smackbook" in your applications folder, you would type "cd /Applicatons/Smackbook" at the terminal prompt. You could then run chmod and all the rest.

For example:

Last login: Tue Dec 11 17:19:41 on ttys000
Deimos:~ dtgibson$ cd /Applications/Smackbook
Deimos:Smackbook dtgibson$

Andrew said...

Hi. Now that I have the permissions set (I did what you said above) and I try to run the script, it says it cannot find the AMSTracker file at ./AMSTracker, which is exactly where it is, in the same directory. Any idea why that isn't working?


David Gibson said...

When you're at the terminal window in the proper folder, and type "ls -la" (which lists all the contents of the folder) do both the files show up?

Also, did you try setting the permissions for both files?

I don't know. Thats odd.

Andrew said...

Yes, I tried setting the permissions for both files, and I still get the same error.

When I type in ls -la to terminal, it lists both files.

Any other ideas? I really appreciate the help.


David Gibson said...

I don't know man, I'm out of ideas. Good luck!

Anonymous said...

hey guys, i can't download the smackleopard.command, maybe someone can send it me by mail? would be very kind of u .. thx
my mail adress is

Abhishek Nandakumar said...

For all those people facing the error which says AMSTracker not found, edit the smackleopard.command file using TextEdit and instead of ./AMSTracker gives the full path of the location of the folder in which you place the AMSTracker executable.

Austin said...

i'm having a similar problem

Can't exec "./AMSTracker": No such file or directory at /Applications/Smackbook/smackleopard.command line 41.
readline() on closed filehandle F at /Applications/Smackbook/smackleopard.command line 42.

any idea what to fix?

Fabiano said...

please change your hosting site.
it sucks.

Fabiano said...

ttt said...

How do you disable the script? It works fine when my macbook is on my desk but if i try to use it in my lap or anywhere else it starts switching spaces like crazy.

If theres a way to temporarily disable smackbook so i can only use it when the computer is on the desk it would be very helpful. Otherwise Ill just get rid of it because I cant get any work done with it switching spaces like this...

Cliff said...
This comment has been removed by the author.
Cliff said...

Steps for the intermediate user.

You need to make all (both) files executable by yourself, group and everyone using CHMOD or some other FTP program like Coda.

Then you need to edit the last part of the *.command file (remove the *.pl extension added by Safari) to reflect the keyboard shortcut used by you to invoke 'Spaces'. The default is [control]-[arrowkey right and left]. Please check with an Applescript reference for the correct key codes / syntax.

You will probably need to adjust sensitivity too. That part is commented/documented in the *.command file and a greater number means less sensitivity.

Then you execute the *.command file in terminal. Use [control]-[C] to terminate.

aidoru said...

I from italy!

best tank you for this tutorial, i wrote a post in italian on my blog: Smack Leopard Spaces !!, and everythings goes fine on my MacBok Pro.

Just a little question on why after the slap it just begins to randomly switch from space to space. :-(

Cliff said...

you'll need to reduce the sensitivity, because after you slap the book, it will continue vibrating. You need to put it on the table.

Jonh said...

hi there. n ty, this thing is cool and work fine for me, if ur spaces change randomly u jst need to adjust sensibility in the script, , its set to 10, too low for me..
on other hand, i have jst one question: how to make this permanently? its work fine, but when i close my terminal all the things turn normal, its possible to make it auto-run at startup?


ps. sorry for my englishXD, im from italy

ttt said...

Mine works ok but its too sensitive. How do you modify it exactly, when i open it in terminal this is all i get:

/Applications/smack/smackleopard.command ; exit;
Can't exec "./AMSTracker": No such file or directory at /Applications/smack/smackleopard.command line 41.
readline() on closed filehandle F at /Applications/smack/smackleopard.command line 42.

[Process completed]

Ive tried it with it running, and off. Any help is appreciated...

Jonh said...
This comment has been removed by the author.
Jonh said...

u do double clik on leo.command?
if u do it, then its wrong.

listen, first u need to put AMStracker in the same directory of ur "smackleopard.command", then open terminal from utility 's folder, now from terminal u must type :
cd Users/urusername/Documents/smackbook
(i had create new folder in documents called smackbook with amstracker n smackleo.command inside)
if u create a folder in other location, es: desktop, u should type desktop instead of documents..

then type : chmod +x smackleopard.command
and in the end

u should get a message like this.
AMS hardware present and initialized

if it going like crazy, disable spaces, or close terminal, then open smackleo.command, in text editor, find this line: if(abs($x) > 12 && $stable > 12) change the numbers (both) choose a value beetwen 15 -20 that work for u.
higher value mean u must hit more hard.

i hope this hlp

ggg05a said...

First and foremost: I have done everything exactly as direct, and all the scripts are running correctly, and placed in the correct location, but when I tap nothing happens. When I execute smackleopard.command it tells me:

"Simulating" AMS hardware in software

But when I tap nothing happens. I have the CTRL + Arrow keys controlling Spaces and it just won't work. Any help out there?


If you are still having the error where it cannot find the ABSTracker, pay attention to line 41 in smackleopard.command

If you have placed amstracker within a folder you need to make smackleopard.command reflect that. Make line 41 look like this (I put mine in a SmackBook folder within the Application Folder)


When the file was freshly downloaded there is a period at the beginning of that string, that period indicates you are going to execute an executable (more specifically amstracker). Because most of us have smackleopard.command within a folder and not simply within our main directory we must remove the period, and then allow terminal to follow the entension.

Like I stated above, it MUST look like this if your smackleopard.command and AMSTracker are within the SmackBook folder which is within Applications:


I also noticed some of you guys were wanting the terminal window to disappear and it automatically start on startup. I wrote a little program, simply down this:

And put it in /Library/StartupItems and restart

A error message will come up asking if you want to alter the security setting to allow the program to work. Click the 'Fix' butten and then click restart.

There you go!

Hope that helps.


Paul said...

amstracker is no longer available to download. Anyone know where to get it from?

Nozrul said...

ams tracker doesnt seem available anymore. How can i get a hold of it?

Anonymous said...

finally got this working, after quite a few problems i stumbled upon the "Simulating" AMS in software error. I had managed to find what i thought was amstracker on the net (this took a while) since was not running for a couple days, however, after getting a hold of the REAL AMSTracker from (it is back up as of this writing) ive managed to get the AMS hardware initilised, and all is almost well, just a minor gripe that im sure is only my problem left to fix. so, for all with the "simulating" error, try downloading the amstracker from osxbook, or email me to send it to u ( it should be exactly 44KB big (the disk image) and the actual file is 60KB(AMSTracker) this is only the required file, not the read me and all the rest. Im trying to compile some scripts into a free painless application (with a nice icon, of course) but it is difficult and im relitively new to scripting programs, i want to get it perfectly right, so all you need to do is install a single application, but ive decided to go all the way and add a configuration wizard for the first time you run it (to reset the ams orientation (this was my problem, in all motion sensing applications(AMSVisualizer, AMS2HID, the levelwidget, etc) , adjust the sensitivity and other things, all with a minute timer that will shut it off automatically so no one has major problems the first time through) needless to say, this will take some time to put together, i want to do it properly and skip through all the hassles we can.

elior said...

hi everybody

i am so hopeless, i tried to get this thing working for like a week, and i am now clueless.
if any one of you that succeeded in making smackleopard work, is kind enough and willing to give me a step by step walkthrough, i would more than apreciate it!!!
my email is

thank you all!

inderpal said...

hey guys i need major help with this one. iv downloaded everything both files and placed them in a folder in my applications . i just can't seem to get anywhere typing in the "su" thing when i open smackbook in terminal, when i do type it in it asks for a password so i type in my user password for my mac but it says sorry again and again.

anyone know the problem?


i would very much apreciate a step by step guide if possible
please please email me at

HardingMatthew said...

Hi, Thank you very much for posting these instructions and I am really excited, but when I ran the script in terminal it said the script was present and executed or whatever and then it started repeating this over and over and crashed my system: "^[[5C"

Thank you very much for your help!


CaveBob said...

=( I dont know what i'm doing wrong. I downloaded the files, extracted amwhatever and put then in a folder (applications/smackbook) then i ran terminal and did the chmod thing, it didnt give me any errors but it didnt give me any results so im not sure if it worked. So i continue on and run it ./smackleopard.command and all it does it generate [[5 (or something like that) everything i tap my screen but nothing changes. =( what step(s) did i miss?

AP said...

I was having trouble with the sensitivity, since my MBP has a baseline X value of ~20.. so I modified the script to do a baseline and track changes rather than absolute values.

I've posted it here. Right-click and save as..

I can now do 3+ Spaces and switch between them sequentially. Way cool.

cesarodilon said...

Hi there i just can´t make it work,how can i make the script executable¡ I followed your steps however i ust can´t make it

Anonymous said...

got it working without terminal.

lot of people are complaining about needing to have terminal open for it to work, all you have to do is force quit terminal (after smackleopard.command is running) this will close terminal but leave the code running. to turn it off, simply open the command again, and close terminal (not force quit). Also if you want it on when you start your comp, add smackleopard.command to your startup items in account prefs, but u need to force quit terminal after starting. ciao, hope this is helpful

Anonymous said...

Terminal answers this to me:
chmod: smackleopard.command: No such file or directory

Whats the Problem. I'm not very familiar with terminal. im donig something wrong. but what?
I got AMSTracker and and i put them in one folder. I think that means in the same directory. And than i ran terminal and typed in chmod +x smackleopard.command. But the answer was chmod: smackleopard.command: No such file or directory. and i can stil not smack my macBook. :(

Anonymous said...

Terminal answers this to me:
chmod: smackleopard.command: No such file or directory

Whats the Problem. I'm not very familiar with terminal. im donig something wrong. but what?
I got AMSTracker and and i put them in one folder. I think that means in the same directory. And than i ran terminal and typed in chmod +x smackleopard.command. But the answer was chmod: smackleopard.command: No such file or directory. and i can stil not smack my macBook. :(

Anonymous said...

right. Ive tryed a lot now.
it kept on telling me that smackleopard.command not exist. Therefor i made the path clear with this. cd /Applicatons/Smackbook.
and i typed in ls -la. and it showed me everything is there so the path must be clear.
So i tryed again and still: no such file or directory.
Than i wanted to make sure im the superuser, which is stupid, because im the only user on my computer. anyway i typed in su and entered my password which was answered by sorry. No idea what the computer feels sorry about. I tryed something else and changed my password, but still "Sorry".
I changed the file to smackleopard.command because i dont know what .pl is for but still no such file or directory.
and than i got angry. because im really not very familiar with the terminal and i hate problems.
I#ve read every comment on this website and noticed non of this problems is answered and it seems not not work for anybody. (one or two maybe...)
So whats the problem. It loks great and it works (For some few). Why not for me and almost everybody else?

Shehzad said...

hi, i've got a slight problem..when i run the script and tap the side of my screen, it's gives a [[5C over and over again, and then crashes my system.

i've got a macbook, i tried playing around with sensitivity settings, it still crashes my system...and help?

Shehzad said...
This comment has been removed by the author.
gio said...

when i type su and the password comes up it wont let me type anything

Sam said...

Hey jason!

Worked perfectly! Thankyou very much!
Is there any way to modify this to interface with itunes
(when you tap it goes forward or back a track)?

Cheers, please reply to my email..

William said...


For anyone interested, here is an Automator workflow I created to start up SmackBook. Add it as a startup item and it will run every time you start your computer:

1. Download the zipped folder below (All required files, not just the workflow, are included)

2. After extracting the files, copy the folder 'smackbook' to your 'Documents' folder

3. Repair permissions if necessary as described in the original instructions

4. Go to 'System Preferences' > 'Accounts'

5. Select your account

6. Click on 'Login Items'

7. Click the '+' button

8. Select the Automator workflow in the 'smackbook' folder in your 'Documents' folder

9. Click 'Add' button

10. Check the 'Hide' checkbox next to the workflow in the list

11. That's it. Now SmackBook will run automatically every time you start your computer.


Miso said...

hi, ther
everythink looks fine till I'm trying to run it. Terminal says:........ ./smackleopard.command
-bash: ./smackleopard.command: is a directory

Urs said...

The first link - to the .command file - appears not to be working. Is this temporary, and will it be fixed?

BTW this looks awesome! Can't wait to set it up! :D

Ben Dodson said...

I get the same problem with the terminal displaying [[5C whenever I try to use smack for spaces. Would love to see it working :-)

David said...

david-claycombs-macbook-pro:smackbook dclaycomb$ chmod +x smackleopard.command
david-claycombs-macbook-pro:smackbook dclaycomb$ ./smackleopard.command
AMS hardware present and initialized

it worked fine the first time through but now everytime i smack the laptop it says ^[[5C^[[5D

any ideas?

David said...

my first install went fine but now every time i smack it terminal says "^[[5C^[[5D"

any ideas?

Eric said...

Re: seeing ^[[5C or ^[[5D after running smackleopard.command, the reason is you have the keystrokes for switching spaces set to something other than Ctrl+LeftArrow and Ctrl+RightArrow. I.e., '^' is the Ctrl key, [[5C and [[5D are the left and right arrow keys.

I use the Command key instead of the Control key with the arrows, and I've seen others use the Option key. Depending on which one you use, change the "using control" phrases in the last two osascript commands in the if-else statement in the bottom of the smackleopard.command file to "using command" or "using control".

Eric said...
This comment has been removed by the author.
Eric said...

...or you haven't followed the directions to configure keyboard shortcuts "To switch between spaces:" for Expose & Spaces in the System Preferences...

Open System Preferences, select Expose and Spaces and set the dropdown for "To switch between spaces:". The basic alternatives are Ctrl+Arrow Keys, Command+Arrow Keys and Option+Arrow Keys.

There are several additional alternatives (e.g., CTRL+SHIFT+Arrow Keys) and I'm sure the osascript statements could be modified to accommodate them, but I haven't bothered to figure that out...

pancakes said...

Very cool. However, compared to using keyboard combination to change spaces, this is much more laggy. I know it's probably because it has to go through an external application that isn't built into finder, but still, it's quite bothersome.

Hope there is a workaround..

racheli said...

how do i know what is the password???