Lead

Jul 2 10 6:25 PM

Tags : :

Often when packing up my Modbook, I'll forget to turn the Bluetooth off before putting the Modbook to sleep. Then, as soon as it slips out of range of the wireless keyboard, it wakes up — not uncommonly inside my backpack. By golly, this is not going to happen again: I've made a “Sleep” AppleScript that turns Bluetooth off before putting the Modbook to sleep. 


There are apparently a couple different ways of using AppleScript to turn Bluetooth on and off. Both are described in this Mac OSX Hints article, I've chosen the faster one, which is also the one adaptable to Macs not running in English.


First, download the Unix utility blueutil from Frederik Seiffert's website. Put it in a suitable location [/usr/local/bin/ is a standard location for Unix tools, but anywhere will do]. Then the following AppleScript will turn Bluetooth off and put the computer to sleep:


try

do shell script "'/usr/local/bin/blueutil' off"

on error

delay 3.0

do shell script "'/usr/local/bin/blueutil' off"

end try


delay 2.0

tell application "System Events" to sleep


You can put this in your pen's pop-up menu, make a Service out of it, or, like me, make an Abracadabra gesture out of it:




EricN