by Adam Pash

Click to viewYou just shelled out a bucketful of clams for your new MacBook and you want to protect your investment. What if a sticky-fingered thief eyes your hot new lappie at the coffee shop? It's easy to add a security system to your MacBook that'll help you ID would-be robbers.


With freeware app iAlertU and some Applescript magic, your MacBook can snag a photo of the thieving scoundrel and upload it to your FTP server automatically. Here's how.


NOTE: iAlertU requires an iSight camera and the motion sensing features built in to Apple's MacBooks and MacBook Pros, so you'd need one of those two computers for this to work correctly. Also, keep in mind that this method is far from foolproof. This won't necessarily save your Mac from being stolen, but hey - it's cool, and it certainly *could* help get your stolen Mac back.

iAlertU - The car alarm for your Mac

In case you missed our original post, iAlertU is a snazzy app that works as an alarm system for your MacBook. After you arm iAlertU with the Apple remote, the alarm will go off if anyone tries to type, mouse, unplug, or power off your computer. When the alarm goes off, iAlertU also snaps a picture of (hopefully) the potential thief and saves the image in your home directory (you'd be surprised how well it actually works - the photo it saves is generally from a few seconds before the alarm goes off, so attempts to avoid being caught by the camera don't generally work). Here's the original video of iAlertU in action:

The problem with iAlertU is that it's really just a noisy deterrent - the hope being that the loud, flashing alarm will scare of would-be burglars. But what happens if the thief isn't so easily scared? Your laptop will have a picture of the thief on it, but it's not doing you any good. So I've put together a couple of Applescripts that will upload iAlertU's capture to an FTP server using Transmit. Below I've put together a very short video to give you an idea of what the Applescripts do:

Here's how it works:

Set up Transmit

If you've got Transmit (a Mac FTP app that we simply love here at LH headquarters), open it up. If you don't have it, well, you might want to consider getting it.

Transmit superior FTP Version 3 of the Transmit Mac FTP client is now on sale. Features include tabbed connections,… Read more


The first thing you want to do is set up a favorite in Transmit. To do so, go to the Favorites tab and hit the plus sign (+) to add a new favorite. Enter your FTP info and you're good to go.

Next, go to the Transfers tab of the Transmit preferences. Where it says "When an item already exists...", change the Uploading files option to "Replace the existing file". This isn't necessary, so if you don't want to overwrite files by default, don't change this setting. You just want to make sure that when it matters, your image capture will be uploaded to the FTP server.


Folder monitors and auto-FTP

So, now that you've got your favorite all set up in Transmit, it's time to set up the first Applescript, which uses a handy Mac OS X feature called Folder Actions. In our case, we're setting a monitor that watches your home directory and activates a script to upload the iAlertU picture if it appears in the folder. Here's how:


Download the iAlertU FTP script /Library/Scripts/Folder Action Scripts .


Turn on Folder actions (if they're not already enabled). To do so, go to Applications -> Applescript -> Folder Actions Setup, and click the checkbox labeled Enable Folder Actions.

Next, click on the plus sign (+) to add the to-be-monitored folder, in this case your home folder. Now click the plus sign (+) on the script side. You should see a menu listing several Folder Actions scripts, including the script you just downloaded. Double click the iAlertU FTP script. The last thing you need to do is create a folder in your home directory called alert . This will come in handy for the next section.


You're all set. Now, as soon as iAlertU's alarm goes off, it'll snap a picture. The picture will go into your home folder, which will fire off the Applescript, uploading the image to your FTP server. When the image is uploaded, it is moved to the alert folder so that we know it was uploaded successfully. To give you an idea of the amount of time this takes, from alarm to completed upload normally takes about 15 seconds (in the video it only took around 12), which is pretty good.

However, if the thief gets you computer turned off before the upload can complete, this script won't work. That's why we head to the second tier of the iAlert FTP upload.


Upload iAlertU image on startup

The next Applescript will check the home folder for the iAlertU picture on startup, and, if it's there, upload it to the server. This way, even if the thief gets your computer home, you've still got a good chance of getting the iAlertU picture as long as he connects to the internet eventually.


Download the Upload image on startup script


Again, open the Applescript file and edit the config section to match your settings. After you've set up the Applescript, you need to save it as an application. Go to File -> Save as..., change the File Format to application, and uncheck the Startup Screen option. Click save. Finally, go to your Accounts settings in the preferences. In the Login Items tab, add your new upload image on startup.app to the list of startup items.


Now, if the iAlertU image was not uploaded the first (or subsequent times), it will continue to try and upload the image every time the computer starts up until it's successful. When it is successful, the image will be moved to the alert folder and the Applescript will no longer attempt to upload it to the server.

This method could definitely be tweaked if anyone out there knows more than me and feels like putting in the time, but as-is it's a pretty good method for bolstering, if not your theft protection, your vigilante justice prospects.


Got any good theft-proofing ideas/methods of your own (even if they're, "don't leave your computer alone")? Let's hear them in the comments.

Adam Pash is an associate editor for Lifehacker who works hard to get a glimpse at the face of evil. His special feature Hack Attack appears every Tuesday on Lifehacker. Subscribe to the Hack Attack RSS feed to get new installments in your newsreader.