« It's "kick the IT guy" season again | Main | Yet another nail in the "Bloggers are Real Journalists" coffin »

A quick "Airplane Mode" script

For those of you wanting a (close to) one step way to toggle airport and bluetooth on and off ala "Airplane mode" on a cell phone:

property bluetoothDaemonPath : "/usr/sbin/blued"
property bounceBlueD : "/usr/bin/killall -SIGHUP blued"
property bluetoothOn : "/usr/bin/defaults write com.apple.Bluetooth \"ControllerPowerState\" 1"
property bluetoothOff : "/usr/bin/defaults write com.apple.Bluetooth \"ControllerPowerState\" 0"
property airportOn : "/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support/networksetup -setairportpower on"
property airportOff : "/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support/networksetup -setairportpower off"

try
set theAirplaneModeRecord to display dialog "Click the appropriate button to enable or disable Airplane Mode on your Mac" buttons {"Cancel", "Airplane Mode On", "Airplane Mode Off"} default button "Cancel" with icon caution giving up after 60
set theAirplaneModeButton to button returned of theAirplaneModeRecord

if theAirplaneModeButton is "Cancel" or "" then
quit
else if theAirplaneModeButton is "Airplane Mode On" then
do shell script airportOff with administrator privileges
do shell script bluetoothOff
do shell script bounceBlueD with administrator privileges
else if theAirplaneModeButton is "Airplane Mode Off" then
do shell script airportOn with administrator privileges
do shell script bluetoothOn
do shell script bounceBlueD with administrator privileges
else
quit
end if
end try

Technorati Tags: ,

Categories:     Other
Posted by John C. Welch at 11:20 | Permalink



Comments

Warning for Notes users: The commenting system uses HTML.
I know this will be scary for some of you, especially Notes fans. However, open standards, rah-rah.
If you want to use less-than or greater-than signs, or other similar characters that HTML reserves,
you'll simply have to learn to do it the HTML way. Luckily, HTML is kind of popular, no matter what
your re-educators have told you, and you can easily find help on the intertubes.
digital.forest Where Internet solutions grow

There, a PayPal Button.

Bing
About the Author
How I do stuff on this site
Family
The Artwork of Melissa Findley
Diane Francis @ the National Post Eric Francis @ the Calgary Sun

BUY MY BOOK! BUY MY BOOK!
Non-DRM eBook PDF:
Get it direct from Peachpit!

Kindle Version:


Dead Tree Version:


Apple Amazon Links
Mac OS X Server 10.6 Snow Leopard

Mac OS X 10.6 Snow Leopard

Mac OS X 10.6 Snow Leopard Family Pack (5-User)

Amazon Book Links
Legacy of Ashes: The History of the CIA

The Donnas: Bitchin'

Wizards at War (The Young Wizards, Book 8)

The Demon's Sermon on the Martial Arts

The Collected Stories of Arthur C. Clarke

JavaScript and Ajax for the Web, Sixth Edition

Awakening Warrior: Revolution in the Ethics of Warfare

FOB Links

Mac Web Writers

Techie Links

Review Victims