Auto Airport Shut off

If you often find yourself working at desk with an Ethernet connection and then using Airport when you're mobile, you have to manually shut off Airport when connected to wired network. Here's an automated way to do that. If you're on battery, it'll save you some minutes of battery life by shutting down Airport when it's not needed.



  1. Copy to /Library/Scripts/
  2. From Terminal windows: sudo chmod 755 /Library/Scripts/
  3. Copy com.mine.toggleairport.plist to Desktop
  4. Open Finder, visit Desktop.
  5. Open new Finder. Visit /System/Library/LaunchAgents
  6. Drag com.mine.toggleairport.plist from Desktop to /System/Library/LaunchAgents
  7. Enter password if asked
  8. Lot out and log back in

If you care about the on-screen notification, install Growly and then growlynotify (command line tool) from the Extras folder. It's a 'nice to have' but not really necessary. I've tested the following scripts on Mac OS X 10.6.8 (Snow Leopard).







function set_airport {




    if [ $new_status = "On" ]; then

/usr/sbin/networksetup -setairportpower en1 on

touch /var/tmp/prev_air_on


/usr/sbin/networksetup -setairportpower en1 off

if [ -f "/var/tmp/prev_air_on" ]; then

    rm /var/tmp/prev_air_on






function growl {


    # Checks whether Growl is installed

    if [ -f "/usr/local/bin/growlnotify" ]; then

/usr/local/bin/growlnotify -m "$1" -a "AirPort"





# Set default values






# Determine previous ethernet status

# If file prev_eth_on exists, ethernet was active last time we checked

if [ -f "/var/tmp/prev_eth_on" ]; then




# Determine same for AirPort status

# File is prev_air_on

if [ -f "/var/tmp/prev_air_on" ]; then




# Check actual current ethernet status

if [ "`ifconfig en0 | grep \"status: active\"`" != "" ]; then




# And actual current AirPort status

air_status=`/usr/sbin/networksetup -getairportpower en1 | awk '{ print $4 }'`


# If any change has occured. Run external script (if it exists)

if [ "$prev_air_status" != "$air_status" ] || [ "$prev_eth_status" != "$eth_status" ]; then

    if [ -f "./" ]; then

"./" "$eth_status" "$air_status" &




# Determine whether ethernet status changed

if [ "$prev_eth_status" != "$eth_status" ]; then


    if [ "$eth_status" = "On" ]; then

set_airport "Off"

growl "Wired network detected. Turning AirPort off."


set_airport "On"

growl "No wired network detected. Turning AirPort on."



# If ethernet did not change



    # Check whether AirPort status changed

    # If so it was done manually by user

    if [ "$prev_air_status" != "$air_status" ]; then

set_airport $air_status


if [ "$air_status" = "On" ]; then

    growl "AirPort manually turned on."


    growl "AirPort manually turned off."





# Update ethernet status

if [ "$eth_status" == "On" ]; then

    touch /var/tmp/prev_eth_on


    if [ -f "/var/tmp/prev_eth_on" ]; then

rm /var/tmp/prev_eth_on




exit 0




<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">

<plist version="1.0">