If you are using a VPN sometimes and you want to change the proxy settings when you launch your VPN:

Create a file in directory /etc/NetworkManager/dispatcher.d/

/etc/NetworkManager/dispatcher.d/20proxyvpn

This bash script will be trigger when a connexion is up or down.

In our case, we only check on tun0 vpn interface.

On up event, we change gnome settings to set the proxy pac file and on down event we reset the proxy to none.

I think this script should be adapt if you are using multiple VPN.

It works if you are using the network manager and gnome.