bynkii (bynkii) wrote,
bynkii
bynkii

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
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 0 comments