6

The Bluetooth / Tethering features in OSX are excellent. But they could be a little bit better. Is there a way to script (via AppleScript?) turning the bluetooth radio on and off, so that I could bind it into a key. No reason to drain battery while not tethered.

It would be even better if the connecting itself could be automated. Now I have to click the Bluetooth icon, then select my phone, and select connect. All unnecessary work I have to repeat many times every day. This could be so much more convinient.

1

2 Answers 2

2

I doubt the following helps, but I cannot test it. Still, maybe it helps you find a solution...

Maybe MarcoPolo can help. It can trigger an action (like: enable bluetooth) when some condition is met (like when some application starts running, or maybe when you are out of reach of some network).

So: if for tethering you start some specific program:

  • Start the tethering application
  • Open MarcoPolo's preferences
  • On the Contexts pane, add a new Context and give it a name like "Tethering active"
  • On the Rules pane, select "Add RunningApplication Rule". The dropdown will show you all applications that are currently running, so you can then select your tethering application. Link that to the Context you just created.
  • On the Actions pane, select "Add ToggleBluetooth Action" and link it to the "arrival" of the Context you just created.
  • Likewise: disable bluetooth for "leaving" that Context

I think there's not really such application, is there? :-(

4
  • There is no such application, it's just integrated into the OSX Bluetooth Preferences pane. The closest "Application" that does this is System Preferences.
    – tstm
    Jan 22, 2010 at 8:37
  • But MarcoPolo does support toggling Bluetooth. It's pretty close already! Now all I need is the connection support.
    – tstm
    Jan 22, 2010 at 8:41
  • 1
    @tstm, what happens to tethering when you disable bluetooth, and then later enable it again? And one can also enable bluetooth using blueutil, frederikseiffert.de/blueutil And after switching on bluetooth with blueutil, maybe you can control other details using networksetup, developer.apple.com/mac/library/documentation/Darwin/Reference/… On my Mac, sudo networksetup -listallnetworkservices does mention bluetooth.
    – Arjan
    Jan 22, 2010 at 9:38
  • Great tip! Unforutnately, digging into the utility, it only supports connecting ppp-connections, not PAN.
    – tstm
    Jan 22, 2010 at 11:41
1

Sure, you can do this.

  1. Open up Automator, and create a service.
  2. Record yourself turnng on/off bluetooth.
  3. Save the service.
  4. Open up the Keyboard Preferences pane
  5. Click the Keyboard Shortcuts tab, and then select Services on the left, and scroll down to General on the right.
  6. Check the box next to your new service.
  7. Double-click to the right of your new service, near the scroll bar, to set a shortcut key.

Hope that helps!

3
  • This kind of works, but the fastest I can get the automator workflow to do this is 5 seconds, and because it uses actual mouse clicks to do it, it's not terribly reliable. It's a step in a good direction, but with all the scripting / object support in OSX, there must be a better way?
    – tstm
    Jan 21, 2010 at 16:59
  • And there's also the problem of not being able to detect if BT is already on or not. The script should be a bit smarter, it could detect the state and only toggle it on if it was off etc.
    – tstm
    Jan 21, 2010 at 17:02
  • It also steals my focus and mouse, thus rendering me unable to do anything else for the same 5 seconds. Not that useful, really. I can perform the action myself in less than that time.
    – tstm
    Jan 21, 2010 at 17:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .