Friday, May 15, 2009

Security Proximity Sensor - iPhone with MacBook on Leopard

For the past few days, I have been playing around with some of the possible things that I can do with the Bluetooth function between my laptop and my phone. So I was thinking if I can use the Bluetooth signal of my phone to control my laptop, i.e. when I am within the proximity of my laptop (with my phone in my pocket), say about 5m, it will lock my computer and do some other things and when I'm back within the proximity, the signal will tell the laptop to unlock the system and back to my working desktop. Sounds cool eh? It's like a wireless key to some of the hi-tech cars nowadays where they automatically unlock and open the door when you get near them :-)

So I visited my best friend, uncle Google and see if there's anyone has done that before. I know that the latest Ubuntu 9.04 has the official BlueProximity built-in so that Linux users can use it with their Bluetooth-enabled phones for proximity detector purposes to automatically lock/unlock the computer when the user (with the phone) leaves/returns to the workstation.

As for Windows users, they can have a look at Blue Lock which serves the same function.

But for this post, I will only be discussing on how to do it on a Mac. Basically the program which will be used is Proximity. So before we begin, first you need to download the following programs:

a) Proximity
b) JackSMS


Basically, JackSMS is a program which will trigger an alarm (in terms of a siren through the speakers) if someone moves the MacBook, close the lid or unplug the MagSafe. And when that happens, you can set it to send the image captured using the iSight camera to a defined email address. Not bad eh? :-D

So once you have done that, install Proximity and run it. There will be an icon on the Menu Bar which looks like an 'X'. Click on it to go into Preferences. Under General, set the Monitoring interval to 10 seconds.



Then under Device, you set the device that you want to pair with and do make sure that you turn on the Bluetooth connection on both your laptop as well as your phone. Once you have done that, you can try to click on 'Check Connectivity' just to ensure that both devices are pairing well.


Make sure that the Bluetooth on your phone is turned on too. Here I use SBSettings instead of going deep into Settings to do that :-)


Next, you'll need some scripts to define your status, either 'Away' from the computer or 'Back' at the computer.



For the 'Away' status, save the following scripts as ProximityAway.scpt using the Apple Script Editor.


tell application "System Events"
set itunes_running to (exists process "iTunes")
end tell
if itunes_running is true then
tell application "iTunes"
pause
end tell
end if

-- Set JackSMS status to on, which also lock the computer
tell application "JackSMS" to set jack status to "on"



___________________________________



As for the 'Back' status, use the following scripts and save as ProximityBack.scpt in the same folder as the previous script file.


-- Pause iTunes (might add in fancy fade later)
tell application "System Events"
set itunes_running to (exists process "iTunes")
end tell
if itunes_running is true then
tell application "iTunes"
play
end tell
end if

-- Set JackSMS status to off, which also lock the computer
tell application "JackSMS" to set jack status to "off"



___________________________________


*Codes courtesy of MatHamlin.com



After that, just make sure that Proximity is using these files for the proximity sensing.



Then, you configure JackSMS to lock the computer when turned on.



Go on!! Have fun now with your new wireless security device :-) Again thanks to MatHamlin.com for the codes and basically everything else.



Cheers



No comments: