Q:

How to programmatically turn on and off bluetooth, wifi and sound on OSX

How can I turn on and off the wifi and bluetooth connections, change the sound and brightness levels on OSX? 

A:

Simply execute the right commands :-) You could probably even use AppleScript.

Wifi: ifconfig en1 off or networksetup -setairportpower off
Bluetooth: You'll probably need http://www.frederikseiffert.de/blueutil/
Brightness: I found this c utility for you: http://mattdanger.net/2008/12/adjust-mac-os-x-display-brightness-from-the-terminal/

It's probably all possible without exec() calls, but it's easier this way.

