Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use an enhanced location changer script Network
MacWorld recently published a list of things they would most like to see in Leopard, and one of the first ones listed was the ability to automatically change a variety of settings according to network location. Several months ago, there was a posting here about a script called locationchanger, and since then, I have significantly expanded upon the original script, so I thought I'd share the fruits of my labors.

locationchanger (20KB download link, MacOSXHints mirror) is designed to automatically reconfigure many programs and resources according to IP address, wireless network ID, or dial-up connections. Currently it's capable of automatically modifying the following:
  • NFS automounts
  • Privoxy settings
  • host file settings
  • default printer
  • Mail server and account
  • iChat status
  • Location setting in Network Preferences
Additionally, if growl is found, it notifies you of the new IP address, location name, and the hardware device of the new connection. Comments welcome!

[robg adds: I haven't tested this one, but I know that location management is a topic of interest, so here it is. Please read the entire Read Me file before proceeding, as there are important notes in there. There's also a simple uninstall script, in case you change your mind.]
  • Currently 2.33 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)

Use an enhanced location changer script | 8 comments | Create New Account
Click here to return to the 'Use an enhanced location changer script' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use an enhanced location changer script
Authored by: joewiz on Aug 07, '06 08:14:36AM

This is a great idea - especially the default printer change. It would be one thing if switching printers was a snappy process in OS X, but on my 1.33 GHz G4 iBook, switching printer is sloooow.

I haven't installed the script yet but am wondering about 2 things:

1. The script requires you to set: "SETTLETIME: the amount of time to wait before running the script again" - what is the recommended short-ish time setting that wouldn't adversely affect performance?

2. Could this script also modify volume level? So at one location (home) the speakers are set to half, and at another (work) they're set close to zero?

[ Reply to This | # ]
Use an enhanced location changer script
Authored by: gghose on Aug 10, '06 11:35:59PM

1. For me the value in the script works fine SETTLETIME=10. But mileage may vary, so simply play with it for your networking environments and see what works.

2. OK, here's what to do for volume changes. Right above the line that reads "osascript /tmp/ascript"

insert the following

#System Volume
if [ -n $VOLUME ]; then
PROGRAM='"System Events"'
echo tell application $PROGRAM to set volume $VOLUME >> /tmp/ascript

Then if you want a location to change the volume simply define VOLUME in the location specific settings, e.g. VOLUME=0 will mute your machine.

If VOLUME is not defined for a particular location, no change will be made.

[ Reply to This | # ]
Use an enhanced location changer script
Authored by: shmuel on Aug 07, '06 08:50:29AM
It would be great to see a script of this sort this tied to something like Plazes as their service makes location determinations based on Mac Address which is more consistent than IP and more unique than SSID.

[ Reply to This | # ]
Use an enhanced location changer script
Authored by: svenbox on Aug 07, '06 11:15:45AM
Here's a quote from the previous discussion regarding the locationchanger script:
It's a trivial addition to grab the MAC address. Basically, grep for 'BSSID' instead of ' SSID', and when you cut, use cut -f2- (instead of just cut -f2).

[ Reply to This | # ]
Use an enhanced location changer script
Authored by: afranz on Aug 07, '06 02:05:46PM
since a while now I using "Location X" and yes its a $20 download but it works, when I come home I just select my wireless network and all settings, proxy, security, mail server ... are switched.

[ Reply to This | # ]
Use an enhanced location changer script
Authored by: olivesoft on Aug 07, '06 07:05:45PM
I used SleepWatcher to trigger when the previously mentioned script is run. It doesn't run continuously, just whenever my PowerBook wakes from sleep.

I tend to think of [Mac] OS X as Linux with QA and Taste.
-James Gosling, Java Architect

[ Reply to This | # ]

Use an enhanced location changer script
Authored by: gghose on Aug 13, '06 07:29:53PM

The package here makes use of the OS X's built-in facility to call programs when networking changes. The script only runs when the network changes, not continuously. This is significantly more flexible than just depending on sleep wake up, since network changes can happen when interfaces are disconnected or due to manual intervention (like connecting with a modem).

[ Reply to This | # ]
Use an enhanced location changer script
Authored by: gghose on Aug 29, '06 12:05:50PM
I've significantly added to the LocationChanger package. It now includes the ability to configure on the basis of gateway MAC address (both wireless and wired), can easily support a large number of locations, can alter volume and iChat settings, and verifies that proxy settings are correct and working.

There is also an included script called locationinfo which displays your current network environment and proxy settings.

The new version is now 0.4 and is available at [link:]

[ Reply to This | # ]