Skip to content

Instantly share code, notes, and snippets.

@jondkinney
Created December 20, 2012 04:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jondkinney/4342948 to your computer and use it in GitHub Desktop.
Save jondkinney/4342948 to your computer and use it in GitHub Desktop.
Toggle bluetooth via AppleScript, which I use with Keyboard Maestro to toggle bluetooth via a hotkey combo
-- This assumes you have both growlnotify and blueutil installed.
-- You can set the path to either/both apps in the script on line 12 and 13
-- blueutil is a command line utility to turn bluetooth on and off and is available here:
-- http://www.frederikseiffert.de/blueutil/
-- growlnotify is a command line utility to post Growl notifications and is available when
-- installing Growl 1.2.2 which is available here:
-- http://growl.googlecode.com/files/Growl-1.2.2.dmg
set blueutilpath to "usr/local/bin/blueutil"
set growlnotifypath to "usr/local/bin/growlnotify"
set sb to last word of (do shell script blueutilpath & " status")
if sb is "on" then
do shell script blueutilpath & " off"
set sb_status to "off"
else
do shell script blueutilpath & " on"
set sb_status to "on"
end if
do shell script growlnotifypath & " Bluetooth Status: " & sb_status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment