Wednesday, March 26, 2008

Toggle Airport Power On/Off with AppleScript

If you want to quickly step down your MacBook's power consumption, or you've accidentally hit "send message" for an incomplete or wrongly destined email etc., you'd need to immediately terminate your Internet connection. The best way I've found for doing that is by toggling your airport's power directly.

First, if you don't have MacPorts already installed, visit The MacPorts Project and follow the installation instructions there.

Then, use the terminal command "sudo port install airport".

Finally, save the script below into a file that you can run from the dock or tie it to a handy iKey shortcut.

-- make sure to first use macports to intall the airport port using the Terminal command "sudo port install airport"
-- the airport -p command returns "Power is on/off." but off is considered an error

do shell script "/opt/local/bin/airport -p"
do shell script "/opt/local/bin/airport -P 0"
on error
do shell script "/opt/local/bin/airport -P 1"
end try


Anonymous said...

Thanks a ton.

Anonymous said...

after installing macports in terminal i get:
sudo: port: command not found

?? any idea?


helveticaman said...

after installing macports be sure to quit the terminal and then restart it to get the new environment variables. you can also verify the macports install by typing "env" in the terminal and looking for "manenv="

Anonymous said...

Who knows where to download XRumer 5.0 Palladium?
Help, please. All recommend this program to effectively advertise on the Internet, this is the best program!

Anonymous said...

thanks for this tip. I'm not too technical savvy, and was wondering how you "save a script" in terms of the last step. Thanks!

Anonymous said...

I love you. Endless thanks and praise. : )