I move around a lot with my laptop – home, church, Panera, airports – and hate having to make changes to various settings each time I connect to a different network.
NetworkManager provides a facility to run scripts when an network interface is brought up or shutdown. If you place a script in /etc/NetworkManager/dispatcher.d and make it executable, it will be run when NetworkManager changes the state of an interface. NM will pass the script the interface name, such as ‘wlan0”, and the status, either ‘up’ or ‘down’.
This is all well and good, but those scripts are run as the ‘root’ user, and I wanted to run scripts as my user, preventing my marginal shell scripting skills from running havoc on the rest of the system. So, I created a quick script to do just that.









