Bluetooth Proximity Detection on OS X

I use this to lock and unlock my Mac, at work, based on the bluetooth connection between my phone and computer. Once my Mac detects that the phone is unavailable it locks itself.

What you’ll need:

  • Proximity 1.0 a free download from Apple.
  • A compiled version of notify.c
    #include
    int main(int argc, char ** argv)
    {
    CFMessagePortRef port = CFMessagePortCreateRemote(NULL, CFSTR("com.apple.loginwindow.notify"));
    CFMessagePortSendRequest(port, 500, 0, 0, 0, 0, 0);
    CFRelease(port);
    return 0;
    }

    You can download a pre-compiled version here, or compile it yourself (Apple’s Dev Tools required) with the command
    cc -arch ppc -arch i386 -o notif notif.c -framework CoreFoundation
  • An Apple Script to set the screen saver
    -- Turn on the screen saver password
    do shell script "defaults -currentHost write com.apple.screensaver askForPassword -int 1"
    set MyName to do shell script "whoami"
    set runFile to "/Users/" & MyName & "/notif"
    -- display dialog runFile
    do shell script runFile
    -- Activate the screen saver
    tell application "ScreenSaverEngine" to activate

    N.B. You’ll need to change “/notif” to match the location if the compiled notif binary
  • An Applescript to unset the screensaver.
    -- Disable the screen Saver Password
    set MyName to do shell script "whoami"
    set runFile to "/Users/" & MyName & "/notif"
    do shell script "defaults -currentHost write com.apple.screensaver askForPassword -int 0"
    do shell script runFile
    -- Turn OFF the screen saver
    tell application "ScreenSaverEngine" to quit

    N.B. You’ll need to change “/notif” to match the location if the compiled notif binary
  • Connect your bluetooth device to the Mac via bluetooth.
  • Run Proximity, set your device, set the Applescripts

Useful Links:

Custom Ringtones and SMS alerts for hacked iPhones

Linux on the Palm

Mobile Youtube Now Working

Microsoft; Why we removed Bluetooth DUN

Pair and Send SMS Messages with OS X

Yahoo does a little Windows Mobile

Smartphone Software

Treo 750 Gets Reviewed

Windows Mobile Naming Scheme