It is painful to turn the proxy on and off in my Ubuntu laptop between office and home. As a lazy guy, I would like to make it automatic. Easy life now Image may be NSFW.
Clik here to view.
Clik here to view.

1) Create 3 scripts named proxy_on, proxy_off and check_proxy under /usr/local/bin.
#!/bin/bash
#proxy_on
gsettings set org.gnome.system.proxy.socks host ‘proxy.company.local’
gsettings set org.gnome.system.proxy.socks port 80
gsettings set org.gnome.system.proxy mode ‘manual’
#!/bin/bash
#proxy_off
gsettings set org.gnome.system.proxy mode ‘none’
#!/bin/bash
#check_proxy
#IP_W is the wireless IP, IP is the wire IP
IP_W=`ifconfig wlan0 | grep ‘inet addr’ | awk ‘{print $2}’ | cut -d’.’ -f2`
IP=`ifconfig eth0 | grep ‘inet addr’ | awk ‘{print $2}’ | cut -d’.’ -f2`
#The second octet of the office IP address is 16.
if [[ $IP_W != 16 && $IP != 16 ]]; then
proxy_off
else
proxy_on
fi
2) Add check_proxy to the auto startup programes by creating the file ~/.config/autostart/check_proxy.desktop
[Desktop Entry]
Type=Application
Exec=check_proxy
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_AU]=check_proxy
Name=check_proxy
Image may be NSFW.
Clik here to view.

Clik here to view.
