Skip to content
automatically change location when mac os x changes wifi connection
Branch: master
Clone or download
Latest commit baf5057 Jan 6, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
LocationChanger.plist fix formatting on plist Dec 6, 2018 Update Dec 20, 2018 use a proper extension for the installation shell script. Dec 6, 2018
locationchanger Fix typo on osascript invocation Jan 5, 2019

Mac OSX Wi-Fi Location Changer

  • Automatically changes the Mac OSX network location when Wi-Fi connection SSID changes
  • Allows having different IP settings depending on the Wi-Fi SSID

Note: Mountain Lion compatible


There are two areas that need to be modified in the locationchanger script, Locations and SSIDs. Both of which are case sensitive.


Edit locationchanger and change/add locations to be set:

Note: Ensure you use the exact names as they appear under "Location" in OSX's System Preferences -> Network

Location_Work="Company Intranet"


Edit locationchanger and add/edit SSIDs to be detected:


Edit/Add SSID -> LOCATION mapping to list:

# SSID -> LOCATION mapping
case $SSID in
	$SSID_TelekomPublic ) LOCATION="$Location_Automatic";;
	$SSID_Home          ) LOCATION="$Location_Automatic";;
	$SSID_Work  ) LOCATION="$Location_Work";;
	# ... add more here

MacOS Notifications

The script triggers a MacOS Notification, if you don't want this just delete the three lines that start with osascript around line 57. If you add or delete Locations, the case needs to be updated.

case $LOCATION in
        $Location_Automatic )
                # do stuff here you would do in Location_Automatic
                osascript -e 'display notification "Network Location Changed to Automatic" with title "Network Location Changed"'

        $Location_Home )
                osascript -e 'display notification "Network Location Changed to Home" with title "Network Location Changed"'

        $Location_Work )
                osascript -e 'display notification "Network Location Changed to Work" with title "Network Location Changed"'
				# ... add more here


Automated Installation



Manual Installation

Copy these files:

cp locationchanger /usr/local/bin
cp LocationChanger.plist ~/Library/LaunchAgents/

Should you place the locationchanger script to another location, make sure you edit the path in LocationChanger.plist too.

Make locationchanger script executable:

chmod +x /usr/local/bin/locationchanger

Load LocationChanger.plist as a launchd daemon:

launchctl load ~/Library/LaunchAgents/LocationChanger.plist


Logfile location can be adjusted in locationchanger, around line 12:

exec &>/usr/local/var/log/locationchanger.log

See log in action:

tail -f /usr/local/var/log/locationchanger.log
You can’t perform that action at this time.