Gnome Proxy Script

By lunixguy

#! /bin/sh
# Switches the GNOME proxy on/off and can take an optional proxy host+port

usage ()
{
cat << CAT
Usage: `basename $0` on|off|switch [host [port]]
CAT
exit 1
}

[ $# -lt 1 ] && usage

case “$1″ in
“on”)
mode=”manual”
;;
“off”)
mode=”none”
;;
“switch”)
case “`gconftool-2 -g /system/proxy/mode`” in
“none”)
mode=”manual”
;;
“manual”)
mode=”none”
;;
*) # why not turn it off
mode=”none”
;;
esac
;;
*)
usage
;;
esac

gconftool-2 -t string -s /system/proxy/mode “$mode”
[ ! -z "$2" ] && gconftool-2 -t string -s /system/http_proxy/host “$2″ &&
gconftool-2 -t string -s /system/proxy/secure_host “$2″
[ ! -z "$3" ] && gconftool-2 -t int -s /system/http_proxy/port “$3″ &&
gconftool-2 -t int -s /system/proxy/secure_port “$3″

Leave a Reply