I was able to implement this functionality for myself using autokey-gtk:
sudo apt-get install autokey-gtk
Essentially, I added a folder in the left-pane of Autokey and associated a hot-key with that folder. Then, under that folder I added 3 scripts to facilitate easier switching between the 3 VPNs I frequent through out my work day. Each script only contains one line.
Script 1 - Switch to VPN 1:
os.system("nmcli con down id 'VPN 2' ; nmcli con down id 'VPN 3' ; nmcli con up id 'VPN 1' &")
Script 2 - Switch to VPN 2:
os.system("nmcli con down id 'VPN 1' ; nmcli con down id 'VPN 3' ; nmcli con up id 'VPN 2' &")
Script 3 - Switch to VPN 3:
os.system("nmcli con down id 'VPN 1' ; nmcli con down id 'VPN 2' ; nmcli con up id 'VPN 3' &")
Now, anytime I hit this hot-key combination I've set, a context menu jumps under my mouse-cursor listing all 3 VPNs. When I click any particular one, it automatically disconnects from any of the other two and connects to the one I've selected.
Unfortunately, I was unable to find a nmcli command capable of disconnecting "all VPNs" that might be currently connected. Instead you have to specify the id of the vpn you want to disconnect. I understand the need to specify an id for connection, but I wish there was a general kill all for disconnecting.
I will try to propose this addition to the nmcli command and post back here at some point.
I was able to implement this functionality for myself using autokey-gtk:
sudo apt-get install autokey-gtk
Essentially, I added a folder in the left-pane of Autokey and associated a hot-key with that folder. Then, under that folder I added 3 scripts to facilitate easier switching between the 3 VPNs I frequent through out my work day. Each script only contains one line.
Script 1 - Switch to VPN 1:
os.system("nmcli con down id 'VPN 2' ; nmcli con down id 'VPN 3' ; nmcli con up id 'VPN 1' &")
Script 2 - Switch to VPN 2:
os.system("nmcli con down id 'VPN 1' ; nmcli con down id 'VPN 3' ; nmcli con up id 'VPN 2' &")
Script 3 - Switch to VPN 3:
os.system("nmcli con down id 'VPN 1' ; nmcli con down id 'VPN 2' ; nmcli con up id 'VPN 3' &")
Now, anytime I hit this hot-key combination I've set, a context menu jumps under my mouse-cursor listing all 3 VPNs. When I click any particular one, it automatically disconnects from any of the other two and connects to the one I've selected.
Unfortunately, I was unable to find a nmcli command capable of disconnecting "all VPNs" that might be currently connected. Instead you have to specify the id of the vpn you want to disconnect. I understand the need to specify an id for connection, but I wish there was a general kill all for disconnecting.
I will try to propose this addition to the nmcli command and post back here at some point.