Code Monkey home page Code Monkey logo

wifi-location-changer's Introduction

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

Configuration

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

Locations

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

# LOCATIONS 
Location_Automatic="Automatic"
Location_Work="Company Intranet"

SSIDs

Edit locationchanger and add/edit SSIDs to be detected:

# SSIDS
SSID_TelekomPublic=Telekom
SSID_Home=HomeSSID
SSID_Work=WorkSSID

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
esac

Installation

Automated Installation

Execute:

./install.sh

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

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

wifi-location-changer's People

Contributors

abencz avatar infn8 avatar kaylukas avatar lrangelaugusto avatar marcool04 avatar mikedevita avatar mr-david avatar red54 avatar rimar avatar rocco avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.