I use ControlPlane, the successor to MarcoPolo, to automatically switch to a specified network location when I arrive at a customer site I frequently visit, or when I arrive back home.

ControlPlane determines where you are or what you are doing based on a number of available evidence sources and then automatically reconfigures your Mac based on your preferences. Evidence sources can include your current location, visible WiFi networks, attached USB devices, running applications and more. You can even write your own evidence sources using shell scripts!

I like synchronizing a bunch of files from a server to my Mac periodically, but only when at my home office.

OS/X’ scselect allows me to obtain the location I’m currently in, so I can, say, set up a cron task to copy files onto my Mac once every thirty minutes:

*/30 * * * * /usr/local/bin/jpm-mac-sync

The script uses scselect to determine whether the Mac is in the office and quietly exits if it isn’t:



loc=`${scselect} 2>&1 |
        sed -n -e 's/^ \*.*(\(.*\))$/\1/p' |
        tr '[:lower:]' '[:upper:]'`

[ "$loc" != 'OFFICE' ] && exit

scp -q SERVER/files ~/directory/files

# do more stuff here ...

You don’t have to use ControlPlane for this to work: changing network locations manually has the same effect.