Stabilised SmackPad

Some of you may know of SmackBook – a way you can switch virtual desktops by tapping your Mac. Michele Campeotto did SmackPad for the Thinkpad.

The problem with Michele’s code is that it had an unacceptably high rate of false positives. So, while here at EuroOSCON, I’ve added stabilisation. That is, my version is very careful about only allowing a desktop switch when the laptop starts in and returns to a stable, non-moving state. So you can tap the desktop backwards and forwards, then pick the laptop up, wave it around, and set it back down again without triggering a false switch. It’s very cool :-)

It does this by keeping an archive of data, and only allowing smacks when the standard deviation is less than a certain value. More details of the exact algorithm are in the comments at the top of the file.

Stabilised SmackPad requires the hdaps driver; “sudo modprobe hdaps” in Ubuntu. More details of the requirements are on the original blog post. Once you’ve loaded the driver and started the script, short, sharp thumps on the side of the screen with two fingers should do it. Remember, you can’t switch it more often than about once every two seconds.

5 thoughts on “Stabilised SmackPad

  1. Sweet. Now what I’d really like is for someone to hook that up so I can use it to work in Firefox, slap one way, go back, slap another go forwards, lean one way scroll down, lean the other way scroll up!

    Oh what fun Thinkpads can be… my far the best non-Apple’s out there.

  2. This is an old post, so I doubt you’ll see it, but do you ever have issues with left smacks? 99% of mine end up flipping as if it were a right smack; the original script doesn’t have this issue, but the original script is also rather unusable.

    Could you point me in the direction of which variables and/or methods I could tinker around with? Thank you very much.

  3. Hi Gervase,

    I’m an old hand at windows and I’ve recently had an itch to try linux. I’m using an IBM t60 thinkpad with the hardware accelerator and I’d like to try this out but i can’t make it work at all. Could you help out a newbie?