2

How can I turn on bluetooth via the terminal / the command line?

topskip
  • 1,142
  • See http://apple.stackexchange.com/questions/8343/is-it-possible-to-disconnect-a-bluetooth-connection-using-applescript – Matteo Jan 05 '12 at 09:45

1 Answers1

1

There is an answer over at Superuser. The last post there is what I found to work best, in a slightly different form. The 'checkbox "On"' did not work for me, but the following code did:

# This is only necessary, if AppleScripts are not yet allowed to change checkboxes
tell application "System Events" to set UI elements enabled to true
# Now change the bluetooth status
tell application "System Preferences"
    set current pane to pane id "com.apple.preferences.bluetooth"
    tell application "System Events"
        tell process "System Preferences"
            # Enabled is checkbox number 2
            if value of checkbox 2 of window "Bluetooth" is 0 then
                click checkbox 2 of window "Bluetooth"
            end if
        end tell
    end tell
    quit
end tell

You can execute this script using osascript.

Update: I now changed the script to just enable Bluetooth. No toggling anymore.

Arne
  • 2,362