Bluetooth Proximity Detection on OS X
- Posted by Jesse David Hollington on March 18th, 2007 filed in Mac OS X
- 136 Comments »
One thing that I’ve been playing with off and on for some time is a small efficient little solution for handling basic Bluetooth proximity detection, specifically for being able to perform certain actions when a cell phone or other Bluetooth device is in range of my Powerbook.
As an IT Consultant, I am frequently working in various locations at different clients’ sites, and it’s nice to have my Powerbook secure itself when I’m away from the machine. In addition, my other objectives are to keep the OS X Address Book application connected and to iSync my phone whenever it moves back within proximity of my machine.
Ideally, I would want to activate the OS X screen saver and enable the password protection when I move away from my computer (out of Bluetooth range), but otherwise I’d prefer to keep the screen saver password off for normal use, as it gets quite annoying when I’m working near the computer to have to continually re-enter my password after I’ve diverted my attention elsewhere for a few minutes (which happens frequently, as often the Powerbook sits to one side of other systems that I’m working with, rather than being in constant use).
Presently, the only software solution that will actually handle this with any kind of transparency from a security point of view is a tool called Home Zone that has been only recently released in beta form. While Home Zone looks like an excellent package to keep an eye on, it’s fairly new and may also be a bit more complex than the requirements of a basic Bluetooth proximity detection system. One neat feature, however, is that it also adds WiFi detection to the mix. Home Zone also includes pre-defined actions to do things like Enabling and Disabling the screen saver password, a task that is otherwise more difficult to accomplish than one might expect.
Unfortunately, as of Beta 7, I had little success getting it to reliably detect the presence of a Bluetooth device even in the simplest configuration, and it became frustrating to have my screensaver kick in on me while I was working on the computer only because Home Zone had lost track of the Bluetooth device.
Another excellent tool that will handle proximity detection as part of its much more robust suite of features is Salling Clicker. This is an absolutely outstanding application, but again one that goes well beyond basic proximity detection. Further, since Salling Clicker is really just AppleScript-based in it’s operations, the basic solution and scripts that I describe below can easily be adapted into that as well (in fact, even though I’m a licensed user and big fan of Salling Clicker, the only reason I’m not using it for this purpose today is that proximity detection is not yet supported with the Nokia E62 that I use).
The tool I ultimately chose for the purpose of the detection itself is a little free app appropriately called Proximity. This is a thin little program that does one thing, but does it well—that is to sit in the background and scan for a given Bluetooth device at regular intervals. When it detects a change in the device’s availability, it simply calls one of two Applescripts: One for the device leaving range, and another for when the device enters range.
So, armed with that I set out to create two Applescripts that would perform the following tasks:
When the Bluetooth Device enters range:
- Deactivate the Screen Saver Password.
- Deactivate the Screen Saver.
- Reconnect the phone to the OS X Address Book
- Sync the phone using iSync
When the Bluetooth Device leaves range:
- Activate the Screen Saver Password.
- Activate the Screen Saver.
Activating the screen saver and performing an iSync are both tasks that are trivial to perform via Applescript. Reconnecting the Address Book and enabling and disabling the screen saver password protection is considerably more complicated, however, as I quickly discovered.
I should point out that most of what I am documenting here has been gleaned from various corners of the web, and therefore most of the ideas are not specifically my own. However, I decided to try and document some of this in one place in order to hopefully save others the several hours of searching that it took me to put it all together.
Activating and Deactivating the Screen Saver
Activating and Deactivating the screen saver itself is trivial to do through Applescript simply through the use of the following two Applescript commands:
Activating the Screen Saver:
tell application “ScreenSaverEngine†to activate
Deactivating the Screen Saver:
tell application “ScreenSaverEngine†to quit
Performing an iSync
Likewise, once iSync itself has been properly configured for your phone, performing an iSync is not much more complicated. A basic sync is performed with the following command:
tell application “iSync†to synchronize
However, for my own purposes, I chose to expand upon this. Specifically, I decided there was no point in having iSync automatically sync more often than every 15 minutes or so. This prevents it from kicking in every time I happen to wander away from the computer and back. The following script will only tell iSync to synchronize if a sync has not occurred in the last 900 seconds (15 minutes):
tell application "iSync" if last sync is less than ((current date) - 900) then synchronize end if end tell
Further, since the iSync window will otherwise tend to come up and get in the way when this happens, I prefer to keep it hidden with the following additional command:
tell application "System Events" to set visible of process "iSync" to false
This will have the effect of running iSync if the phone has not been synced in the last 15 minutes, and immediately hiding the iSync window from view. The iSync will continue to run in the background until it completes.
Reconnecting to the Address Book
Although Bluetooth support in the OS X Address Book is a very cool feature, the reality is that it has been poorly implemented up to this point in terms of it’s ability to stay connected to a Bluetooth phone, or even in terms of making this process scriptable via Applescript.
Fortunately, this was discussed some time ago in the Salling Clicker forums and incorporated into the proximity scripts that are included with Salling Clicker. The solution, it would seem, is to toggle an internal Address Book preference to force it look for its associated Bluetooth device the next time it starts up, and then just shut down the Address Book app and restart it. This is accomplished with the following snippet of code, which is a simplification of code pulled from the “Keep Address Book Connected†script included with Salling Clicker
do shell script "defaults write com.apple.AddressBook ABCheckForPhoneNextTime -boolean true" try tell application "Address Book" to launch tell application "System Events" set the visible of process "Address Book" to no end tell end trytell application "Address Book" if not unsaved then try quit delay 1 end try end if end tellPlaced within the script that executes when entering proximity, this will toggle the option to find a Bluetooth device ON in the Address Book preferences, and then shut down and restart the Address Book app. It’s messy, but it does work.
(I’m sure I’m not alone in hoping that Apple makes this function accessible through Applescript in Leopard).
The Final Challenge: Enabling and Disabling the Screen Saver Password
The final hurdle in this process was programmatically changing the password protection on the OS X screen saver. While this is handled very elegantly by the Home Zone application that I mentioned at the beginning of this article, I wanted to find a way to do it programmatically through Applescript myself for various reasons. It turns out this process was slightly more complex than I had initially suspected.
Firstly, the preference that determines whether the OS X screen saver asks for a password is stored within each user’s local preferences, specifically in the
com.apple.screensaver domain. The preference file itself is a little tricky, as it is named based on a host ID. Fortunately, it can be accessed using the built-in “defaults†command-line tool. The specific key is “askForPassword†and contains an integer value of zero or one to determine whether the screensaver prompts for a password or not.The following command, executed in terminal or from a “do shell script†within Applescript, will set this value to enable password protection on the screen saver:
defaults -currentHost write com.apple.screensaver askForPassword -int 1
This is well-documented in several places on the Internet, although there a couple of important things that should be noted.
Firstly, it is necessary to specify the “-int†parameter. Without it, the “defaults†command will write the value as a string value, which will be treated as an “OFF†setting regardless of the content. More specifically, anything in that key other than an integer 1 will disable the screen saver password.
More importantly, however, this setting does not take effect immediately…. Either the System Preferences application must be opened and other changes made, or the user must log out and back in. This is because the password requirement is only read by the “loginwindow†process.
By default, changes in the “System Preferences†app in OS X will send a notification to the loginwindow process to re-read these settings. However, to change the setting programmatically and have it take effect immediately, it’s necessary to find an alternative way to refresh the loginwindow process.
After much digging, the solution was found in a thread on the macosxhints forum, in the last post by Guillaime O. Specifically, Guilaime provides a snippet of C code that can be quickly and easily compiled into an executable to perform this specific function.
#include <CoreFoundation/CoreFoundation.h> 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; }
This code can simply be compiled with the built-in C compiler on OS X (if you have the Development Tools installed), and then simply put somewhere in the path. Then, immediately after running the “defaults†command to set the screen saver password state, simply call this application to refresh the “loginwindow†process and re-read the “askForPassword†setting.
For my own purposes, I just went with the suggested name of “notif†for the executable, but it can of course be named anything you like.
The Final Result
So, after all is said and done, the final result is the following two scripts:
Entering Proximity.scpt
-- Disable the screen Saver Password do shell script "defaults -currentHost write com.apple.screensaver askForPassword -int 0" do shell script "notif" -- Turn OFF the screen saver tell application "ScreenSaverEngine" to quit tell application "Address Book" if not unsaved then try quit delay 1 end try end if end tell -- Reconnect to the Address Book do shell script "defaults write com.apple.AddressBook ABCheckForPhoneNextTime -boolean true" try tell application "Address Book" launch end tell tell application "System Events" set the visible of process "Address Book" to no end tell end try -- Synchronize the Device tell application "iSync" if last sync is less than ((current date) - 900) then synchronize end if end tell tell application "System Events" to set visible of process "iSync" to false
Leaving Proximity.scpt
-- Turn on the screen saver password do shell script "defaults -currentHost write com.apple.screensaver askForPassword -int 1" do shell script "notif" -- Activate the screen saver tell application "ScreenSaverEngine" to activate
Other Possible Tricks
One other approach I had tried was to make use of the “CGSession†command to do a lock by returning to the actual login screen (effectively a fast-user-switching feature that presents the login screen without logging the user out). While this was a very neat solution, it lacked the intuitive “unlock†feature, since once returning to the login screen, there was really no way to get back in without a password (at least not a simple method that I have yet discovered without embedding my password somewhere in the file).
However, for those interested, the following Applescript entry will accomplish this task:
do shell script "/System/Library/CoreServices/ Menu\\ Extras/User.menu/Contents/Resources/CGSession -suspend"
This works reasonably well, and the entering proximity script will even run in the background, so the only disadvantage is that you are forced to log in manually when you return to the computer, and there is a small delay in this process.
Once thing I was able to do with this, however, was to combine it with another tool, the excellent SleepWatcher daemon, to allow me to run shell scripts when the computer wakes or sleeps. I simply instruct SleepWatcher to run a script including the above command with a slight delay to allow it to complete, and then whenever the computer goes to sleep, my session is returned to the log in screen.
While the Bluetooth proximity detection feature will also address this (if the computer is awakened without the necessary Bluetooth device nearby), this option is slightly more secure, and allows for the ability for somebody else to log onto the computer if necessary (a screen saver password would restrict access to the currently logged in user only).
References & Acknowledgements
Again, most of what is discussed in here has been gleaned and put together from information in various places on the Internet. Specifically, the following should be acknowledged:
Proximity 1.0 A very simple and effective free Bluetooth Proximity detection tool for Mac OS X Home Zone beta 7 A very slick up-and-coming solution by Jonas Witt to set parameters based on “Zones†which are in turn based upon WiFi and Bluetooth proximity. Salling Clicker 3.0.1 Jonas Salling’s absolutely outstanding Bluetooth remote control and proximity detection app, and the source for the Address Book reconnect script included above. SleepWatcher 2.0.4 A neat little daemon by Bernhard Baehr to monitor and execute shell scripts based on sleep and wake events. Mac OS X Hints Most of the solutions and script snippets regarding the screen saver password protection came from the Mac OS X Hints forum. Specifically, the simple but indispensable C code for the “notif” application was contributed to these forums in a post by Guillame O.
March 18th, 2007 at 19:01
Well, regarding most of the rquirements, Salling Clicker does it extremely well, including locking the computer on leaving the BT range, keeping the phone connected to the address book etc. The only thing it doesn’t do is the iSync autosync, but then it is easy to add applescripts to Clicker’s list of actions so…
March 18th, 2007 at 21:19
I’ve been using bluephonelite for a long time now and it has many of these features built in. It def. doesn’t do the syncing which is awesome but it is pretty good. I wonder if they have plans to implement any of the things you posted here because i don’t want to have to separate applications handling different bluetooth actions.
March 18th, 2007 at 22:18
Since you are using iSync do you need to reconnect to the address book?
March 18th, 2007 at 22:30
Thanks for such a thorough explanation.
March 18th, 2007 at 23:02
Could you please make the scripts available for download or for copy? It appears that the entire page is an image and I cannot copy the text / there is an error in my code and it will not run. Thanks.
March 18th, 2007 at 23:30
>>Could you please make the scripts available for download or for copy? < <<
I second that. If you’re going to post your code, it would be great if you’d provide a download link. Or at least post it on your web page in a format that we could easily copy/paste. Thanks.
March 18th, 2007 at 23:48
I was able to make the applescript stuff with a little trial and error. However, I don’t have the developer tools or the knowledge to make the notif script work. Any help would be appreciated.
March 19th, 2007 at 0:13
It’d also be sweet if you could post the notif executable
Thanks!!
March 19th, 2007 at 0:34
I’m interested in the log-out feature, and you mentioned a security risk in the form of putting your username & password in the script to be able to log back in automatically.. let’s just assume i’d like to take that risk of an auto log-in, can you tell me what additional code i would need to use in an out-of-range script?
March 19th, 2007 at 1:23
n00bs read this:
HOW TO COMPILE THE C CODE
to compile the C code, you need to have the developer tools installed. they are on one of the Mac OS X install dvd that came with your Mac. then, paste the source code into a file called notify.c and compile it with the following command:
gcc-4.0 -o notif -framework CoreFoundation notif.c
this will create the ‘notif’ program that the applescript is looking for
ALSO
you don’t need to change your path to allow the applescript to call the C program that you just created. you can just compile it anywhere, like your home directory for example, and change the applescript line to
do shell script ”~/notif”
you can compile the binary in any directory you like, just specify its location in both of the applescript files.
March 19th, 2007 at 5:11
Very interesting and useful. Thanks mate.
However, for the love of ___ please make your website/post accessible to the audience! Using images, especially in such a long and useful post, is more than just 1995 – it’s plain stupid and devalues the content IMHO. And white text on a black background? argh…
March 19th, 2007 at 5:36
The text is just one big image! Where’s copy + paste?!
March 19th, 2007 at 6:11
I wrote down both Apple Scripts and the C Program. The 2 scripts, the compiled version of the C program including source code is available for download here
March 19th, 2007 at 6:28
Heres an idea – use TEXT not a fecking image of some text you retard.
March 19th, 2007 at 7:30
The text is text, not one big image.
Use the source, Luke.
March 19th, 2007 at 7:30
Ignore people like the above poster (its automatically generated like that in iWeb), anyway thanks for these scripts.
March 19th, 2007 at 7:46
Yes, I’m sorry it’s so ugly…. In fact, it’s uglier than I expected, as I was supposed to be using web-safe fonts, and didn’t really bother to check it after I published it.
Of course, I also didn’t expect almost 15,000 hits in less than 24 hours….
At any rate, my grand little experiment of iWeb is now officially over. This page will shortly be appearing back on my WordPress blog.
March 19th, 2007 at 9:00
Brilliant!!! excellent explanation.
March 19th, 2007 at 10:03
There is also a GREAT FREE app called Romeo. IT does the same thing. It actually has customizabe menu that you can access from your cell phone. When your phone rings it automatically reduce your itunes music for your to hear the phone ring and pick up the phone…——————-
http://www.mostofmymac.com
March 19th, 2007 at 12:13
Not to highjack the topic, but…. iWeb creates giant images of text?
I had no idea until I came across this post. That’s just horrible.
March 19th, 2007 at 12:28
If you do not have a compiler, can you simply use the notify file or notify.c file that was posted on the above web site from meckimac.
I put these two files in my home (~/notify) but now when I run the scripts I get the following error message:
sh: line 1: /Users/tal/notif: Permission denied
Any advice?
March 19th, 2007 at 12:37
As posted in my on blog.
chmod 755 /Users/tal/notif
will fix it – you are just missing execute permissions.
March 19th, 2007 at 15:18
[...] started out using the Applescripts written by Jesse David Hollington, ended up only using a small portion of it. Jesse’s scripts include turning the screensaver [...]
March 19th, 2007 at 16:31
The same article appeared on goitexpert.com a few weeks ago, but it was for Linux. Here’s the link to the article.
March 19th, 2007 at 16:32
Linking didn’t work, here’s the link with html a tag
http://www.goitexpert.com/entry.cfm?entry=Use-Your-Bluetooth-Cell-Phone-as-a-Proximity-Card-for-your-Laptop
March 19th, 2007 at 19:52
I am tring to use this great program but I am getting an error “cannot execute binary file” while writing this I thought about tring it in terminal as “su ~/notif” ask me for password. Put in the password and then I get “su: Sorry” then a command prompt any one out there think they can help. I would greatly appreciate
Mike
March 19th, 2007 at 20:31
I am getting the same problem. Is the c file compiled for intel or ppc? oh is it possible to compile for only one? I have no idea what I’m talking about, I’m just throwing ideas out there. I am running a PPC.
March 19th, 2007 at 21:19
I love this. I’ve wanted to do this for some time now.
I’m pretty new to applescript. Is there a way to quit isync and address book after the sync?
March 19th, 2007 at 22:23
Found a working notif fule : http://digg.com/apple/Bluetooth_Proximity_Detection_on_OS_X#c5752438
March 19th, 2007 at 22:43
[...] 하다보니 좀 ì´ìƒí•œ ì œëª©ì´ ë˜ì—ˆë‹¤. ì›ì œëŠ” “Bluetooth Proximity Detection on OS X“. 한마디로 ìžì‹ ì˜ ë¸”ë£¨íˆ¬ìŠ¤ 장비가 ë§¥ë¶ì´ë‚˜ ì•„ì´ë§¥ë“±ì— ì ‘ê·¼í• ë•Œ [...]
March 19th, 2007 at 22:54
When I try to make the script, I get a message asking me where ScreenSaverEngine is. Help?
March 20th, 2007 at 1:22
I’d also be interested in a login script, security isn’t a huge issue as I share my mac with my wife, but I’m the password enabled admin user and I prefer to keep it that way.
Anyone have a sample of this?
March 20th, 2007 at 6:00
For some reason notif.c won’t compile here :(
OS X 10.4.9
XCode 2.4
I get the following:
/usr/bin/ld: Undefined symbols:
_CFMessagePortCreateRemote
_CFMessagePortSendRequest
_CFRelease
___CFStringMakeConstantString
collect2: ld returned 1 exit status
Ideas? Thanks!
March 20th, 2007 at 6:04
Working now. I followed the link to Guillame’s post and followed his compile instructions. Someone kick me in the head.
March 20th, 2007 at 6:54
[...] HTML, JavaScript, Ajax runtime so we can all develop a new generation of widgets on steroids. – Some cool Bluetooth + AppleScript magic, trigger actions on OSX by mobile phone proximity. – Sony looses [...]
March 20th, 2007 at 7:49
[...] tombe sur cet article (anglais) qui me donne envie de laisser mon boulot en plan et de rentrer chez moi pour bidouiller ma machine. [...]
March 20th, 2007 at 8:19
I had an idea that’s vaguely related to this, maybe if you think it’s possible you might email me and encourage me to follow it through.
I’d like my mobile phone to keep an eye on my macbook when I leave my bag down in a room. So if someone tries to leave the room with my laptop my phone will alert me.
I think it may be possible because we can resume the mac with a bluetooth keyboard or mouse so there must be some communication going on.
I’ve only had my mac a few weeks so haven’t done much with it but I’ve done Java Bluetooth programming on my phone before.
March 20th, 2007 at 8:22
[...] Read more… Tags: bluetooth device, cell phone, powerbook, proximity detection, specifically Posted on Tuesday, March 20th, 2007 at 7:22 pm and under category News. You can read any responses through the RSS 2.0 feed. You can give a response, or trackback from your site. « Freeware Utilities for Windows – Password Recovery Utilities Data centre security breaches – 3:1 it’s an inside job » [...]
March 20th, 2007 at 9:48
Oscabat,
I had this same problem and this is how I fixed it. Go to /System/Library/Frameworks/ScreenSaver.framework/Resources/
Then drag the ScreenSaverEngine.app to your Applications folder. It will automatically make a copy. Now the script will work. I don’t know if there is another way of doing this, but if anyone knows be sure to let everyone know.
Dizzle
March 20th, 2007 at 10:10
[...] Bluetooth Proximity Detection on OS X [...]
March 20th, 2007 at 10:18
Strangely, the “ScreenSaverEngine” is locatable on all four of my machines I’ve tried it on, including my wife’s rather non-customized iBook. It’s not in the Applications folder on any of these. I’m thinking some other piece of software may have exposed it to the AppleScript libraries as well (I do have Salling Clicker installed on all of my machines, for example).
Another method that might work is to go into Script Editor and choose File->Open Dictionary and then browse to the “ScreenSaverEngine” piece to add it to AppleScript’s dictionary list.
On another note, just to clarify a couple of other earlier questions…. The connection to Address Book that is being performed here has no relation directly to iSync. Rather, I keep the phone connected to the OS X Address Book so I can get notification of incoming calls and dial directly from the Address Book. Since it’s notorious for not being intelligent enough to stay connected or reconnect itself when the phone comes back into range, it’s necessary to kludge it with the above script.
Note that there are a number of other really useful tools that can do this instead, but I prefer the simplicity of Address Book for this right now (BluePhoneElite is my other preferred solution, but the current beta is not 100% reliable for me just yet).
iSync can be quit following the sync operation simply by issuing a “quit” command, but there would need to be some logic put in place to make sure that it wasn’t actually syncing at the time (otherwise it will try to quit in the middle of a sync). Note as well that even the attempt to call iSync (to compare sync times, for instance), will result in the app starting up again. As a result, I just tend to leave it running but hidden (which is what the above scripts do).
If anybody has any better suggestions on how to check the last sync time without actually starting iSync, please feel free to share them. I suppose the script itself could flag the last sync time somewhere, but that would only be valid for iSync operations triggered by the script (as opposed to by other methods).
Finally, as I noted above in the original article, Salling Clicker is a fantastic solution to handle the proximity detection itself, but it’s Applescript based too, so you could really just include the following Applescripts in your phone events in Salling Clicker to expand it’s functionality. One thing that Clicker can’t do by itself is handle the enabling/disabling of the screen saver password.
Add to that the fact that unfortunately my Nokia E62 isn’t supported by Salling Clicker yet, and I’m forced to use “Proximity” instead to trigger those events, which is rather ironic considering that Salling Clicker is otherwise always running on my Powerbook.
March 20th, 2007 at 10:19
Hi,
would this still be usefull when there are multiple bluetooth devices around? like the bluetooth wireless keyboard and mouse??
thanks!
March 20th, 2007 at 10:24
The short answer is yes. “Proximity” and the other similar solutions are based on a specific device ID, not just any Bluetooth device in general.
One disadvantage is that most of these will only look for one specific device. So you could configure it to use your phone or your Bluetooth headset (for example), but you’d only be able to use one of those devices.
The exception to this is the Home Zone application that I mentioned above…. It allows for Zones to be set up based on the presence of any or all of a specified list of devices, including WiFi access points as well (so you could, for example, trigger behaviour only when you’re within range of your home WiFi access point and your Bluetooth phone and Wii are both in range).
March 20th, 2007 at 10:40
Not sure if this has been addressed yet, but I couldn’t figure out how to get the script to wake the display. I use my laptop at work frequently and if I’m away from my desk (and my laptop), it’s usually long enough for the display to go to sleep. Sure, I could make the display sleep period longer, but I was sure there was another answer… and here it is :) If you want your display to wake when you get back to your computer add the following to your “entering” applescript:
tell application “System Events”
key code 53
delay 3
key code 53
end tell
March 20th, 2007 at 12:10
[...] and the tutorial can be found HERE [...]
March 20th, 2007 at 18:25
[...] BlueTooth proximity detection, make your Mac do stuff when your phone gets near it would be cool to make it update web site when near (via http://www.makezine.com/blog/archive/2007/03/bluetooth_proximity_detec.html?CMP=OTC-0D6B48984890) (tags: mac hardware bluetooth phones) [...]
March 20th, 2007 at 19:01
Very, very nice – I’ve been longing for something like this for a while now (as Salling Clicker didn’t support my Nokia E61 and wasn’t free) and you’ve made me very happy.
Thanks for this!
March 20th, 2007 at 19:07
[...] sync my Nokia E61 with my mac over bluetooth when I came home from work every day. I came upon this site reading blogs today and it seems to do just what I want, for free. Fuck you, Salling [...]
March 20th, 2007 at 21:24
[...] The Technocrat » Bluetooth Proximity Detection on OS X very clever. could be useful as well (tags: bluetooth detection osx) [...]
March 20th, 2007 at 22:45
[...] friends at Make just noticed this write-up of how to use a nifty little OS X app that detects Bluetooth proximity (not surprisingly, called [...]
March 21st, 2007 at 1:17
Hey,
I did a spotlight search for “ScreenSaverEngine” and nothing turned up on my iMac or my MacBook PRO.
:’(
Gusti
March 21st, 2007 at 1:45
Great article detailing all the steps you went through along the way, I’ll certainly be trying this implementation – thanks!
March 21st, 2007 at 1:49
Good tutorial. I also could not locate ScreenSaverEngine on my MacBook Pro, so I made the following AppleScripts to do the above:
http://www.tswartz.com/files/Archive.zip
Hopefully they help someone else. :D
March 21st, 2007 at 2:07
Thanks so much!
I’ve been looking for a way to automatically perform an iSync when my phone comes within range for months!
March 21st, 2007 at 8:01
See post 39 above by Dizzle.
Contrary to popular belief, Spotlight does not search everything on your computer. There are many internal system files and frameworks (of which ScreenSaverEngine is one) that are excluded from Spotlight indexing, otherwise the average Mac user would never be able to find anything on their Mac due to the signal to noise ratio of a search picking up on a bunch of irrelevant internal files.
The file itself is located specifically in:
/System/Library/Frameworks/ScreenSaver.framework/Resources/
March 21st, 2007 at 9:17
So, how hard is it to spoof a device ID?
March 21st, 2007 at 9:20
[...] ieri al tipo che ha scriptato un affarino per bloccare/sbloccare il proprio Mac OSx se questo e’ vicino o meno al proprio cellulare Bluetooth, mi e’ venuto da fare la [...]
March 21st, 2007 at 10:25
A bit buggy.
1) When the device leaves the bluetooth range, but someone moves the mouse, the screensaver with password protection won’t activate.
2) When the screensaver is active and the login window is visible, and the device then enters the range, the screensaver is not deactivated. Instead, you have to klick away the window (abort) and then move the mouse again for deactivating it.
3) After the device is in range, AdressBook and iSync are started and stay in the dock. I’d prefer them to not show up at all, or at least go away again.
How can I get rid of these issues?
March 21st, 2007 at 11:02
[...] post by Jesse outlines some of the ways you could set up some proximity based tasks on Mac OS X using applescript and some other stuff tied together. Nice and simple with endless [...]
March 21st, 2007 at 11:05
script works fine on my macbook pro when run in script editor but when added to Proximity they don’t do anything. When I press “test” in proximity nothing happens? I have tried having the script files stored in “documents” and then tried with them in my Home folder. Any thoughts or help?
Thanks
March 21st, 2007 at 11:27
@Alex: It is possible to spoof Bluetooth device IDs, but since this requires a pairing with the device in order to work, I’m not sure a spoofed device ID would be enough to trigger the proximity event. This would, of course, be a function of the “Proximity” app itself and the underlying OS X as to whether a spoofed but unpaired device would be enough to trigger a proximity reaction. I haven’t actually tested it myself, as it’s not particularly easy to spoof a Bluetooth ID. I know for certain however that simply using another device with the same name is not enough.
Regardless, this isn’t really designed to be a highly secure solution for a whole number of reasons. It’s just useful to prevent the casual passer-by from snooping. A more secure solution would be to use the “CGSession” method that I described later in the post to actually return to the login screen.
@Kris:
Some of these issues are simply limitations of the way the screensaver and Applescript interact, although it should be possible to script around them. Issue #1 is probably the hardest, as it’s simply a timing issue, but if security is a concern, again the CGSession method is more secure and will reliably secure the computer regardless of what somebody may be doing on it at the same.
Issue #2 might be solvable with some basic UI scripting to send an “ESC” key sequence before deactivating the screen saver.
Issue #3 could also be addressed with some simple script modifications, although as I described in another comment above, you’d have to monitor the iSync process in order to only send a “quit” after it finished syncing. As for Address Book, since the whole point of the script is simply to keep it connected to the phone, you don’t even need that portion if you’re not going to be using it (in which case the Address Book app won’t start at all).
@charanti: I store all of my scripts under /Library/Scripts, and they work fine from there. I’m not sure why they might not work from other locations, but you’ll also want to ensure that they have a .scpt extension just in case that’s an issue.
March 21st, 2007 at 11:29
Incidentally, as another thought: some have mentioned in other comments elsewhere that they use Entourage. I’m also an Entourage 2004 user, and am using Entourage’s own “Sync Services” interface (introduced to Entourage in an SP update last March) to get my calendar and address book info from Entourage into Sync Services. My iSync used in the above examples takes the data directly from Entourage 2004 via Sync Services. I can see the data in iCal and Address Book, but I don’t use iCal at all, and I merely use Address Book for quick contact lookup, dialing/incoming call notification and interaction with other OS X software such as BluePhone Elite (of which I am also a happily registered user).
Also, just to reiterate: The point of the “Address Book” portion of the scripts above is to keep the phone connected to the address book for incoming call notification. It is not required for iSync, so if you don’t desire incoming call notification, or don’t use your Address Book app for that purpose, then you can actually omit that portion of the script.
March 21st, 2007 at 11:50
Thanks Jesse, storing the scripts in /Library/Scripts fixed the problem.
March 21st, 2007 at 19:17
Jesse:
Thanks for your suggestions. :)
@ #1: Hmmm then I’ll just forget about “perfect security” for now. ;)
@ #2: Nice idea, but doesn’t seem to work. I tried adding these lines to the entering script before the part with “ScreenSaverEngine”:
tell application “System Events”
keystroke esc
end tell
But unfortunately, this doesn’t close the login window. And when no login window is there, suddenly the screensaver won’t deactivate at all (but no login is required anymore). Well, since I have no experience with AppleScript, maybe I’m doing something wrong. Do you know how to make it work?
@ #3: That incoming call notification requires BluePhoneElite, doesn’t it?
March 21st, 2007 at 19:35
Jesse, I’m with you on the iWeb experiment. I bought iLife ‘06 just to get iWeb, and was very disappointed with its (lack of) blogging capabilities. Back to Blogger for me.
March 21st, 2007 at 20:21
[...] The Technocrat » Bluetooth Proximity Detection on OS X (tags: howto mac mobile software tutorial bluetooth applescript Proximity phone osx nokia hacks apple programming tips technology) [...]
March 22nd, 2007 at 8:11
[...] je dat kan fixen lees je hier, je hebt er wel een mobieltje en een laptop met Bluetooth voor [...]
March 22nd, 2007 at 14:21
A couple of years ago I wanted a quickish way to toggle the screensaver password myself and I came up with this applescript that does it. It basically just automates what you as the user would do. It probably takes a lot longer to run than the solution presented here but it might be helpful to someone.
tell application “System Preferences”
activate
set current pane to pane “com.apple.preference.security”
end tell
tell application “System Events”
if UI elements enabled then
tell window “Security” of process “System Preferences”
click checkbox “Require password to wake this computer from sleep or screen saver”
end tell
else
tell application “System Preferences”
activate
set current pane to pane “com.apple.preference.security”
display dialog “UI element scripting is not enabled. Check \”Enable access for assistive devices\””
end tell
end if
end tell
delay 2
tell application “System Preferences”
quit
end tell
March 22nd, 2007 at 17:40
[...] manipulate my Mac to do my bidding. Check this out: I’ve got Proximity installed (thanks to this page). It detects when your Bluetooth device (my phone) is within range. I’ve also got iAlertU [...]
March 22nd, 2007 at 18:11
Thank you very much Jesse. I came across this page while looking for a way to keep Address Book connected and you have saved me a lot of searching.
One thing I would like to mention is that a part of the Address Book re-connect script is not needed if done first.
“defaults write com.apple.AddressBook ABCheckForPhoneNextTime -boolean true”
The above, After running once will always make Address Book force a bluetooth connection every-time it starts and can be run before hand from Terminal and removed from the script. If Address Book is then placed in the Login Items it will have a bluetooth connection at startup.
Also could you please offer some help in making iSync quit safely after a sync or if it does not need to sync. I would like to add this but I just don’t know how.
March 22nd, 2007 at 18:21
Actually, the ABCheckForPhoneNextTime entry is required in the event that the address book is disconnected before quitting. It seems that this setting is not a “sticky” default, per se, but is rather only used to indicate that a device was connected when the Address Book app last terminated. In my own testing, disconnecting the phone from the Address Book and then restarting the Address Book app caused it to come up without bothering to check.
As for the iSync question, Jonas Witt (author of the Home Zone app described above) provided me with a couple of script snippets, which I believe he has now also partially incorporated into an action in Home Zone itself. Put together, a suggestion for a revised iSync script would look something like the following:
tell application "System Events" set isync_running to name of processes contains "iSync" end tell tell application "iSync" if last sync is less than ((current date) - 900) then -- sync and minimize synchronize repeat while syncing delay 0.3 end repeat if isync_running is false then quit end if set miniaturized of first window to true else -- don't sync, quit if iSync wasn't running if isync_running is false then quit end if return "No iSync needed" end if end tellThe one disadvantage of the “delay” portion above when incorporated into a program like Home Zone or Salling Clicker is that the script does not complete until after the iSync has finished (since it stays in a loop while the sync is running), and therefore won’t necessarily return control back to the application. However, for use with the Proximity application, this shouldn’t really be a problem, as the Applescript runs in the background. However, you should still make sure the iSync is the last action listed in the Applescript, unless you actually want to delay other actions until after the iSync completes.
March 22nd, 2007 at 18:39
Thanks for the extended iSync script.
I must admit that I have yet to install Proximity as I was testing the scripts first (to learn from them) as I am an AppleScript Noob, So my testing may be wrong. After I ran ABCheckForPhoneNextTime true, I opened and closed Address Book (manually) a few times and it always made a connection. I then ran ABCheckForPhoneNextTime false and repeated open/close and it never made a connection. When I then went to the AppleScript, just removing ABCheckForPhoneNextTime from the script did not work as expected but, After a slight modification (below) it does.
tell application “Address Book”
if not unsaved then
try
quit
delay 1
end try
end if
try
tell application “Address Book” to launch
tell application “System Events”
set the visible of process “Address Book” to no
end tell
end try
end tell
March 23rd, 2007 at 9:59
Jesse:
This was my first experience with Applescript and with all the excellent information in your post everything went just fine and I got the script working.
I’ve got my Powerbook set to sleep after 5 minutes and noticed that if I’d been away longer than that the script would shut down the screensaver only to have it immediately start back up. I think the screensaver timer was “on hold” waiting to start the screensaver (that was already started) based on the timer value. I really wanted the screensaver to kick in after a few minutes though because I work in a crowded office situation where I can be in a meeting 10 feet from my desk and thus still without bt range. I got around this by doing a delay and issuing a second screensaver shut down command in the script. I also then immediately turn the password feature back on, so that if I’m away from my desk but within range, the timer activated screensaver will kick in and my computer will be password protected.
My lingering problem is that every few minutes my Blackberry seems to miss or be tardy in responding to Proximity. So, I’m sitting here typing and suddenly my screensaver pops up only to immediately shut down again (since I’ve set Proximity to check every 5 seconds). Any ideas on how to get it to do something like require 2 failed responses before it runs the script? I’m also using a bt keyboard and mightymouse, so I don’t know if the problem is there or just the Blackberry – but the Mac doesn’t seem to be loosing track of either the mouse or keyboard.
March 23rd, 2007 at 13:45
Jesse you are right, I had not taken into account Address Book not being connected by bluetooth. I apologize, please dismiss what I have said above.
I tried using your revised iSync script but I could get it to work as I expected. I did find a solution though and it’s posted below.
—Synchronize the Device
tell application “iSync”
if last sync is less than ((current date) – 900) then
synchronize
end if
end tell
tell application “System Events” to set visible of process “iSync” to false—iSync Quit, Set First Delay to be Longer than Your Sync Time
tell application “iSync”
if syncing is true then
quit (delay 60)
else
quit (delay 5)
end if
end tell
March 23rd, 2007 at 20:11
I am an avid user of DeskShade and love the ability to lock my machine without using the Screen Saver. When i saw this wonderful article I was impressed by the great ideas. After using it for a few days though, I did notice a few problems with the Screen Saver lock which can be found here. I replaced the lines of code for the Screen Saver lock with ones that will make use of DeskShade’s lock feature instead. This also eliminates the need for the notif file as well. I hope this helps some of you DeskShade users out there.
– Anthony
Entering Proximity.scpt
tell application “DeskShade”
unlock
end tell
Leaving Proximity.scpt
tell application “DeskShade”
lock
end tell
March 25th, 2007 at 17:42
[...] Bluetooth Proximity Detection on OS X: ” [...]
March 26th, 2007 at 9:56
Hi:
After using this I can’t get OS/X 10.4.9 to ask for the password any more – even if I disable the tool and tick the check box in System Prefs by hand. Any ideas?
J.
March 26th, 2007 at 10:49
[...] Bluetooth Proximity Detection on OS X Large list of scripts and howtos for configuring screensavers, call forwarding, syncronization, and so on for your phone when it gets near your computer. (tags: macosx apple applescript mobile todo automation howto tutorial bluetooth) [...]
March 26th, 2007 at 11:26
[...] Using Bluetooth as a proximity sensor to lock/unlock your OS X laptop:http://www.technocrat.ca/?p=44 [...]
March 26th, 2007 at 15:38
If I let this ping by Treo 700p at will (every few seconds) while I’m sitting at my laptop, I can almost watch my phone’s battery life slip away. I’d like to change the frequency of the ping based on whether or not I’m nearby. So If I’m in front of my laptop, it only pings every couple minutes but if it sees I’m gone it switches to every couple seconds.
March 27th, 2007 at 0:17
mopac01: I’ve had a similar problem with my proximity setup.
Although probably not the best workaround, I’ve put in a 30 second delay at the start of my “leaving proximity” script, and have my scanning repeat set to 10 seconds.
[code] delay ## [/code] where ## is the time in seconds you want to delay
That way, if for some reason it doesn’t detect my phone when i’m nearby it still gets three tries before it goes to screensaver. this seems to be working for today at least!
Got the idea from the iSync quit workaround (so thanks to whoever that was!)
March 27th, 2007 at 16:04
Joe: Although Proximity itself is not scriptable, you can tell Applescript to terminate the app, update the default refresh interval, and then restart it.
Try this snippet of Applescript code in your leaving and entering proximity scripts. Modify the interval value as appropriate for your needs:
This has the effect of shutting down Proximity, updating it’s default timerInterval, and then restarting it again.
March 30th, 2007 at 2:46
[...] more information visit The Technocrat. Social [...]
April 5th, 2007 at 19:37
[...] The Technocrat » Bluetooth Proximity Detection on OS X Great article on doing simple proximity detection triggers with BT. (tags: bluetooth awesome hacks howto mobile OSX tutorials sync proximity) [...]
April 6th, 2007 at 14:48
I’ve been working on a similar project recently, but the end goal is a lot simpler.
All I want is a script that will connect to my wireless mighty mouse when I turn it on, so that I don’t have to run the dialog every time, or flick my bluetooth on and off (which works, strangely enough.)
The problem I’ve had is that I don’t even know where to find a reference for bluetooth commands in OSX, making it more or less impossible to do what I want.
Any hints? I’ve tried using tell to tell system preferences to attempt to connect to it in the background every 15 seconds, but no luck whatsoever…
April 7th, 2007 at 17:07
#77 Jason:
I’m having the same issue. After using a tool (namely HomeZone) that uses this trick the screen NEVER asks me for a password anymore!
This is a big problem!
Anyone? Anyone? Buller?!
April 10th, 2007 at 1:42
I can’t seem to get Proximity to run. I doubleclick the app, and it creates a new proccess, but nothing appears. :(
I will try rebooting and see of that fixes it
April 10th, 2007 at 1:55
Man, I am such an idiot. For other’s who’ve had a brain fart; that big new X in the menu bar is how you access the Proximity application.
April 17th, 2007 at 8:29
[...] The Technocrat » Bluetooth Proximity Detection on OS X (tags: bluetooth hacking mac apple) [...]
May 1st, 2007 at 23:45
[...] mac to support the N95. I’m sad that although I can have the Mac unlock the screen when my bluetooth MAC shows up, it won’t show me the callerId on the mac as apparently the N95/OS X support doesn’t go [...]
May 2nd, 2007 at 13:53
Is there a way to sync ical this way also by integrating it into the script. I really don’t know apple script and was just wondering if it is possible
May 2nd, 2007 at 15:05
Actually, iSync will do both iCal and the Address Book, provided they’ve been configured in the iSync application itself for your particular device.
The pieces in the script above for the Address Book are to connect it to the phone for dialing, sending SMS messages, and receiving incoming call notification. The Address Book app references in the script have nothing to do with syncing the content, as this is entirely handled by the iSync application (and therefore that portion of the script).
May 6th, 2007 at 4:13
[...] The Technocrat » Bluetooth Proximity Detection on OS X – Very cool app – unlock your mac automatically when you are near it. Now if only Sony Ericsson could start supporting the Mac! [...]
May 15th, 2007 at 2:41
I’m very inexperienced but got everything here to work except for the part written in C code. Is it possible to do this through applescript?
June 14th, 2007 at 12:53
to LCM 191 – yes: the following will set the password to the opposite of what you want, then use GUI scripting to change the option in system preferences (which will automatically do the notif, without requiring the mysterious c code). then it launches the screensaver – do the same (only setting the default to 1) on returning, in order to turn off the password.
do shell script “defaults -currentHost write com.apple.screensaver askForPassword -int 0”
tell application “System Preferences”
activate
set current pane to pane “com.apple.preference.security”
tell application “System Events”
click checkbox “Require password to wake this computer from sleep or screen saver” of window “Security” of process “System Preferences”
end tell
quit
end tell
tell application “ScreenSaverEngine” to activate
June 15th, 2007 at 14:43
and to the person who wants to unlock the screensaver, even if if the authenticate window is open, try inserting the following script before you tell the screen saver to quit . . .
tell application “System Events”
if exists window “Authenticate” of process “SecurityAgent” then
click button “Cancel” of group 2 of window “Authenticate” of application process “SecurityAgent”
end if
end tell
. . . you’re welcome
July 15th, 2007 at 0:15
You could try MarcoPolo to get the functionality you want. Plus a whole lot more!
(I’m a very happy user, and it’s free!)
Version 2, which is currently under development has even better tools to do what you want.
September 19th, 2007 at 21:28
I don’t use the screensaver in favor of simply turning of the screen (power saving over eye candy) of my powerbook. Would anyone care to explain how to make that adaptation to the script?
thanks
October 17th, 2007 at 22:10
[...] to think about it. All of these things auto-sync without any action on my part. In fact, I added this script which not only syncs my phone when I walk in my apartment, I’ve added the option that logs my [...]
October 30th, 2007 at 23:41
Has anyone noticed that on leopard after the script activates it’s screensaver the system then activates a second screensaver when the non-activity threshold is passed? I’ve kind of solved the problem by having the out of range script not immediately start the screen saver and just wait for the system to start the screensaver. Does anyone see a better way to keep the automatic screensaver initiation without the double screensaver?
November 26th, 2007 at 18:01
Well…if this compiling is so simple as the author says, i must be a retard.
Installed DevTools from the install dvd that i got with my mac.
I can surely say that i understand as little of this as a cat understands the workings of a particle accelerator.
I have a MacBook Pro with OSX 10.4.11 that is soon to be replaced with Leopard.
Can someone help me compile this code that is described on this webpage?
I just want to make the proximity stuff work and not use so much time on this project.
I appreciate if you send me an email about this.
Thanx :)
November 27th, 2007 at 19:50
I have an update to this, I am using Leopard and have found a way to activate and deactivate the screen saver password from applescript without using the executable posted here.
The code to do this is
—Activate screensaver password
tell application “System Events”
tell security preferences
set require password to wake to true
end tell
end tell
—Deactivate screensaver password
tell application “System Events”
tell security preferences
set require password to wake to false
end tell
end tell
I hope it’s useful to someone, this proximity script is great!
December 15th, 2007 at 12:35
Thanks Herón! That helped a lot. On Leopard I also had to change the ‘tell application’ part as follows:
—Activate the screen saver
tell application id “com.apple.ScreenSaver.Engine” to activate
AND
—Turn OFF the screen saver
tell application id “com.apple.ScreenSaver.Engine” to quit
January 10th, 2008 at 21:16
Maybe i am kinda dumb :)
But i am unable to make this work like evertything else in OSX does; like a charm. In fact, it doesn’t work :(
Can someone that have a MacBook Pro with Leopard installed (and maybe also a SE K750i mobile phone) PLEASE help me?
– The scripts i can find on this page (although i am nt sure if they work in Leopard)
– I wonder if i need the C code snippet at all. I know NOTHING about C and how to make usable files. I got a friend of mine to help me and i THINK we goot it right.
If someone that have the above mentioned OS and machine would be so extremely kind to make a step-by-step list for little dumb me to follow, it would make me very happy and prevent me from ripping more of my hair from mu skull in pure frustration.
Please mail me the solution to my problem. I hope someone will.
January 10th, 2008 at 21:26
one more thing;
i use a program called BluePhoneElite which also have some kind of proximity thingie buildt in.
I reckon that having several bluetooth apps talking to the mobile would make problems. Therefore i wish to have one app do it all.
Therefore i wonder; can i use these scripts that you describe in any app that can be set up to do stuff when the mobile leaves or enter proximity?
January 10th, 2008 at 21:27
my mail, of course:
suuhlem@gmail.com
-sorry—January 11th, 2008 at 11:03
Post #102 above shows a Leopard-compatible version of the Applescript that eliminates the need for the notif C script that was originally required for Tiger.
With Leopard, you can just use the above script or a variation on that and don’t need any of the external calls for “Do Shell Script” nor the C code.
BluePhoneElite and/or Salling Clicker can also both be used to run these scripts based on proximity, so if you’re already using that program for other reasons, you’re better off with that rather than Proximity. The Proximity app was originally used because it was lightweight, simple and free for those folks who only want Proximity detection and don’t need the more advanced features.
Both BPE and Salling, however, provide the ability to run scripts based on proximity, so you can just drop those scripts into the appropriate places in those applications and it should work just as well.
January 18th, 2008 at 20:37
Thanks, Jesse David Hollington :)
You summed it up for a newbie :)
January 19th, 2008 at 9:48
Ok! :))
It almost seems to work now. Through iSync is left open after sync.
And i have another problem; if i have messed around on my mobile so that iSync requires confirmation upon syncronization, it is left open.
Here is how it is on my computer:
—-ENTERING PROXIMITY————Disable the screen Saver Password
tell application “System Events”
tell security preferences
set require password to wake to false
end tell
end tell—Turn OFF the screen saver
tell application “ScreenSaverEngine” to quit
tell application “Address Book”
if not unsaved then
try
quit
delay 1
end try
end if
end tell—Reconnect to the Address Book
do shell script “defaults write com.apple.AddressBook ABCheckForPhoneNextTime -boolean true”
try
tell application “Address Book”
launch
end tell
tell application “System Events”
set the visible of process “Address Book” to no
end tell
end try—Synchronize the Device
tell application “iSync”
if last sync is less than ((current date) – 900) then
synchronize
end if
end tell
tell application “System Events” to set visible of process “iSync” to false—————————————-
And here is the other one
——LEAVING PROXIMITY——-
—Activate screensaver password
tell application “System Events”
tell security preferences
set require password to wake to true
end tell
end tell
—————————————
I have 10.5.1 Leopard installed.
What’s wrong?
January 19th, 2008 at 16:59
One more thing…it seems that the screensaver is kicking in very random like.
When i am working on the mac, it kicks in too.
I hope you don’t feel that i am spamming the forum, it is not my intention :-/
PS: I see that the formatting of my text further up was messed up. But it is written in the correct syntax in the script editor.
February 4th, 2008 at 7:20
I ended up with removing everything concerning screen saver in the applescript.
It was irritating when the screen saver kicked in e.g when i was writing something or generaly using the computer.
If someone have a solution to that, please do not hesitate to tell.
The only problem now is with the sync process; some times iSync says that it is unable to synchronize with my mobile. This has not been the case earlier.
Well, well…
February 6th, 2008 at 20:19
Well…i guess one of four things has happened:
1) You all grew tired of me and decided to boycott me by not posting any more posts at this forum. :)
2) Noone is around anymore.
3) Noone actually have a solution to my problem.
4) Noone cares.
Well, i don’t know what happened. And Mr. Hollington doesn’t have an email adress that i know. And since i still have the same problem, i must find my answers somewhere else.
But if someone gets a sudden burst of kindness and decides to give me a working solution to my problem, please email it to hotrodny@gmail.com since it will be some time until my next visits here.
February 23rd, 2008 at 9:15
Hi, apologies for the long delay in any kind of response, but I guess the e-mail notifications of new comments weren’t working quite as well as they should have been, so I didn’t see these additional comments until I came back to visit the blog.
Getting to your specific issues, the only thing I can think of is that there may simply be a connectivity problem with the Bluetooth between your phone and your Mac. I’ve had similar problems with different phone models… The Bluetooth doesn’t “wake up” quickly enough for iSync to recognize it, and the proximity detection sometimes sees the phone as “missing.” This problem can be exacerbated when you’re using other Bluetooth devices as well, such as a mouse or keyboard, or even if there are a lot of other Bluetooth devices in close proximity.
Sometimes deleting the pairing and re-pairing the device with your Mac will also help clear up these issues, both with proximity detection but more importantly with iSync itself.
Preventing the screen saver from kicking in is generally as simple as telling Proximity to make some additional scans before determining that the device has truly gone away. This means it will also be a bit longer before your screen saver kicks in when you actually do leave proximity, but it will prevent these false positives from occurring.
The setting in Proximity can be found on the “Device” tab of your Proximity preferences, under the “Error Correction” heading.
The iSync issues are a bit trickier to solve, depending upon what confirmation prompts you are seeing. If it’s simply the query about more than 5% of your content having changed, you can reconfigure this threshold in your iSync preferences, although of course you risk the potential for problems if you actually did have a situation where the data on your phone had been incorrectly modified (this warning is designed to prevent that by warning you of significant differences).
March 17th, 2008 at 18:54
[...] échte geek zijn als ik niet verder ging kijken. Via m’n eerdere google opdracht kwam ik op deze pagina terecht, die het één en ander aan handige scripts [...]
April 7th, 2008 at 13:45
Hi,
Does anyone have a copy of the Proximity utility that they could email me as the download link is currently broken (no idea how long it has been broken for! Thanks.
Chris
April 7th, 2008 at 20:38
Same here, can’t find the Proximity Utility?
demoncratique @ yahoo . ca
Much apreciated.
Thanks!
April 18th, 2008 at 22:32
I actually had a simpler way to activate/deactivate the screen saver password. :
——————————————————
tell application “System Preferences”
activate
set current pane to pane “com.apple.preference.security”
tell application “System Events”
click checkbox 0 of window 0 of process “System Preferences”
end tell
quit
end tell
———————-
the same code will work in both scripts, since it’s changing the checkbox in ur system prefs. Surprisingly, it still works when ur screensaver is active. Only thing is that u have to be sure that it’s set to NOT ask u for ur password when u r leaving. Or maybe there’s an if…else command to check the value of the checkbox and select/unselect it as needed. eliminates the prob of using shell scripts.
April 23rd, 2008 at 9:16
[...] I’d write them down here for you lovely readers to use. I found some part of these at the Technocrat [...]
April 27th, 2008 at 5:49
[...] and iSync, and doesn’t close them. To make it more seemless, I used a script I found at The Technocrat to start and stop iSync without interfering with your work. Here’s how I did [...]
June 30th, 2008 at 20:50
Well, the screensaver thingie does not work. I am not directly question the Applescript that mr. Hollington provided. It may be that my mobile (K750i with firmware R1DB001) may be too old. But i like it and i actually USE my mobile and is not dependent of the newest and hottest.
As long as the shit works, i am satisfied.
But i guess it will soon be replaed with a newer one…K810i or w660i…anyone that have tips on which mobile will work, please msg me.
February 15th, 2009 at 5:46
Hello.
I’m new there
Nice forum!
March 1st, 2009 at 19:31
This is exactly what I’ve been looking for.
The link to Proximity from Apple’s download site is now 404.
The developer’s site is here: http://reduxcomputing.com/
March 7th, 2009 at 11:18
[...] just found a very nice post describing nice things to do with Bluetooth. By using the Proximity tool, my MacBook Pro can [...]
March 15th, 2009 at 19:02
[...] Bluetooth Proximity Detection on OS X [...]
March 20th, 2009 at 9:47
very intresting
May 8th, 2009 at 10:16
When my mb pro checks to see if my phone is in range (every 10 seconds), my might mouse seems to lose connection. It still works, but it moves very slowly. Anyone have this issue or a fix? I can’t use proximity if this is not fixable.
May 19th, 2009 at 0:02
hello I am having trouble because the X is not appearing in the menu bar after the application is started
June 11th, 2009 at 10:31
Greetings,
What is the cheapest web hosting company?
I’m want to set up a web site for my boss.
Thank you,
-Nick
September 1st, 2009 at 12:26
I am having issues with this on Snow Leopard (OS X 10.6). When I come back into proximity, instead of waking, I get a black screen with a cursor. The only way I can get back into the laptop is to turn off my bluetooth, wait for the away script to lock the machine and activate the screen saver, and then log into the computer with my password. My guess is that there is some new security feature in Snow Leopard that is preventing auto login?
September 9th, 2009 at 11:57
Hi! I was surfing and found your blog post… nice! I love your blog. :) Cheers! Sandra. R.
September 26th, 2009 at 17:55
Has anyone found a fix for the blank screensaver issue in snow leopard 10.6?
October 2nd, 2009 at 3:07
Chris,Kevin, I am having the same issues on Snow Leopard, I don’t know if either of you are the users on this forum or have seen it, but just fyi:http://discussions.apple.com/thread.jspa?threadID=2133574&start=15&tstart=1
December 9th, 2009 at 17:59
It looks like there’s an application that may finally do what we want in Snow Leopard. Unfortunately right now it only supports the iPhone and iPod touch. They say, however, that they plan to include support for other bluetooth devices in the future. The application is called Airlock: http://themha.com/airlock/
December 13th, 2009 at 17:49
I’m not that happy with AirLock. It produces so much activity on the disk and the items it consists of are scatered all over the drive. Proximity is so slim and elegant and I would really love to find a solution, to get it run again in Snow Leo.
January 6th, 2010 at 0:14
Hi guys, I’m a teacher and I’m trying to develop an app to notice if my students are or are not attempting to my classes. To do so I wonder if it is possible to check every MAC address of every student bluetooth phone previously assigned in my app’s data base. So, if the student is in the class room, I would no it checking his phone proximity. Any one can help me accomplish this goal. I work with applescript. Thanks.
January 8th, 2010 at 22:28
I have the same Snow Leopard problem. When I come in range I get a black screen with the cursor…I hope this gets worked out somehow…