Tags

, ,


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 🙂
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
ping_test=`ping -c 2 proxy.company.local | grep bytes | wc -l`
if [ “$ping_test” -gt 1 ]; then
proxy_on
else
proxy_off
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
download_icon
Advertisements