This video shows a clever use of the Apple sudden motion sensor. Simply tap the side of your MacBook and the desktop switches. Sadly, the URL at the beginning of the video is password protected. Here's hoping somone releases the code.
This video shows a clever use of the Apple sudden motion sensor. Simply tap the side of your MacBook and the desktop switches. Sadly, the URL at the beginning of the video is password protected. Here's hoping somone releases the code.
| # | Blogger | Posts | Cmts |
|---|---|---|---|
| 1 | Cory Bohon | 89 | 1 |
| 2 | Robert Palmer | 64 | 44 |
| 3 | Steven Sande | 58 | 22 |
| 4 | Scott McNulty | 40 | 0 |
| 5 | Mat Lu | 40 | 10 |
| 6 | Dave Caolo | 37 | 0 |
| 7 | Erica Sadun | 28 | 2 |
| 8 | Brett Terpstra | 23 | 0 |
| 9 | Mike Schramm | 20 | 1 |
| 10 | Michael Rose | 11 | 32 |
| 11 | Christina Warren | 10 | 38 |
| 12 | Joshua Ellis | 3 | 2 |
| 13 | Lisa Hoover | 2 | 6 |
| 14 | Chris Ullrich | 2 | 2 |
Other Weblogs Inc. Network blogs you might be interested in:
Reader Comments (Page 1 of 2)
5-24-2006 @ 1:35PM
kevin said...
this was found via digg, by the way.
Reply
5-24-2006 @ 1:36PM
Scott McNulty said...
It actually wasn't, kevin.
If I found it via digg I would have said so, but thanks anyway! :)
Reply
5-24-2006 @ 1:49PM
andy said...
cant be healthy but it waaayyy cool, macbook typewritter.
Reply
5-24-2006 @ 2:16PM
marc cardwell said...
ok, what is the liquid app thing he moves right then back left? its just the kind of useless thing i'd like to have.
Reply
5-24-2006 @ 2:39PM
moose said...
It's Desktop Manager - basically, the same as "virtual desktops" on Unix.
BTW, I'm working on a generic "smack" code now. I'll release it when done; I'm thinking of "smack pinball" or something.
Reply
5-24-2006 @ 2:54PM
Bwhit said...
How about Smack the Weasel?
Reply
5-24-2006 @ 3:33PM
Adrian vG said...
SmackBook PRO :)
So does the desktop manager support the sudden motion sensor?
Reply
5-24-2006 @ 3:58PM
Lars said...
I must say it looks rather fake. The screen seems to be superimposed on it. Also, from what I know, the motion sensor doesn't erm, sense this kind of motion.
Ah well.
Reply
5-24-2006 @ 4:14PM
Nick Postagulous said...
Heck, I know how to fake this. And the camera shake does look fake. Keeps the exact same perspective while the image moves around slightly. No tilt, just lil micro pans. But, whatever, not something I need. How about keys that do that if it's such a brilliant idea.
Reply
5-24-2006 @ 4:20PM
Peter said...
It also seems as if the screen changes a instant before his hand comes in contact with the screen.
Reply
5-24-2006 @ 4:37PM
Jason Piper said...
Ok... first get AMSTracker (http://www.osxbook.com/software/sms/amstracker/). I ganked this first from elsewhere as a rough draft. I use YouControl Desktop to control desktop switching (shift+control+option+command+f). Get this script (http://www.no-rulz.net/screenswitch.py). Put AMS and the screenswitch.py in the same folder and run this ./AMSTracker -u 0.1 -s | python screenswitch.py
With any luck it should run
Reply
5-24-2006 @ 4:38PM
Jeduthun said...
It is a fake. Look at the image I've just uploaded:
http://rapidshare.de/files/21295708/fake.jpg.html
The screen changes BEFORE the guy's fingers hit the Mac.
Reply
5-24-2006 @ 5:41PM
Amit Ahluwalia said...
Just tried AMSTracker and when you run the command in terminal the screen just keeps flipping until I hit cmd+c to make it stop. Anyone else get it to work?
Reply
5-24-2006 @ 6:23PM
Aitor Garcia said...
The script works ...almost well. You must modify the line:
THRESHOLD = 8 # lower numbers makes this more sensitive
A value from 7 to 10 seems to be more useful than the default 3.
Execute only "./AMSTracker -u 0.1 -s" without the piped process to see the reaction of the AMS and the change the script accordingly
Reply
5-24-2006 @ 7:05PM
Victor Agreda, Jr. said...
Uh, couldn't you just trigger a desktop switch via built-in microphone? That's right, the motion sensor doesn't double as an earthquake alarm. It can't detect minute vibrations like a few fingers smacking the screen (pounding on the body, maybe).
But smacking the side would easily spike the audio input.
Reply
5-24-2006 @ 7:08PM
Andrew Harrison said...
first off, Jeduthun, ya jackass, clearly that's his hand on the way off the screen after tapping it. watch it again.
and also,
he's released the code
http://blog.medallia.com/2006/05/smacbook_pro.html
So it doesn't get lost when Digg grabs hold:
---- START CODE
Desktop Manager patch
First, you'll need to be able to control Desktop Manager from outside. Cocoa has a nice class called NSDistributedNotificationCenter which can handle simple message passing between applications. DM uses a notification center internally to send "next desktop", "previous desktop" commands to itself, so the patch just replaces the normal version with the distributed version. I added the following to WorkspaceController.m, inside the init method:
[[NSDistributedNotificationCenter defaultCenter] addObserver: self
selector: @selector(selectNextWorkspace)
name: NOTIFICATION_NEXTWORKSPACE
object: nil
];
[[NSDistributedNotificationCenter defaultCenter] addObserver: self
selector: @selector(selectPreviousWorkspace)
name: NOTIFICATION_PREVWORKSPACE
object: nil
];
To control all the windows in the system, an application needs to have access to the CGSUniversalConnection; only one application can have that at a given time, and the Dock tends to win the battle. Desktop Manager sneakily uses mach_inject to inject its own code into the Dock application. There's still no x86 version of the sweet, sweet mach_inject library (Wolf! Help us!), so not all the Desktop Manager features will not work on Intel.
Reading the sensor
For the actual sensor reading, I used amstracker by Amit Singh. He does not allow redistribution, so you'll have to get it directly from the source.
notify: Remote control for Desktop Manager
This 15-line program lets you send random notifications to any running application.
#import
int main (int argc, const char * argv[]) {
[[NSAutoreleasePool alloc] init];
if(argc != 2) {
NSLog(@"Use: %s notification-name", argv[0]);
return 1;
}
[[NSDistributedNotificationCenter defaultCenter]
postNotificationName: [NSString stringWithCString: argv[1]]
object: nil];
return 0;
}
Compile it with gcc -framework Foundation -o notify notify.m, then call it with ./notify SwitchToNextWorkspace.
Actual motion interpreter
You can do arbitrarily fancy stuff here; this 10-line Perl script just checks to see if the horizontal acceleration exceeds some threshold in either direction, and calls the notify program.
use strict;
my $stable;
open F,"./AMSTracker -s -u0.01 |";
while() {
my @a = /(-?d+)/g;
print, next if @a != 3;
# we get a signed short written as two unsigned bytes
$a[0] += 256 if $a[0] < 0;
my $x = $a[1]*256 + $a[0];
if(abs($x) < 20) {
$stable++;
}
if(abs($x) > 30 && $stable > 30) {
$stable = 0;
my $foo = $x < 0 ? 'Prev' : 'Next';
system "./notify SwitchTo${foo}Workspacen";
}
}
---- END CODE
he's also got it as a zip
Reply
5-24-2006 @ 7:38PM
Mart said...
Well I got it working. You have to read the instructions, guys. Also you have to use a PPC mac to compile DesktopManager - mach_inject doesn't compile on intel. Fun but not super usable...
Reply
5-24-2006 @ 9:02PM
michel said...
wonderful.
but I'm disappointed there are no more mach inject for intel. it was a terrific idea (and a very dangerous one ! my dear hobbit) to improve DM.
the last comment is wonderful. source code, explanations and all the references. many thanks mr Harrison!
Reply
5-24-2006 @ 10:27PM
Jeduthun said...
Andrew, do you feel compelled to insult other people to prove them that they are wrong?
You must feel very insecure, po' boy.
Reply
5-25-2006 @ 12:40AM
DVDLV said...
Excellent !
Reply