25 lines
332 B
Bash
25 lines
332 B
Bash
|
#!/bin/bash
|
||
|
# https://robertbasic.com/blog/toggle-a-vpn-connection/
|
||
|
|
||
|
VPN=$1
|
||
|
|
||
|
if [ -z "$VPN" ]
|
||
|
then
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
ACTIVE=`nmcli con show --active | grep "$VPN"`
|
||
|
|
||
|
if [ -z "$ACTIVE" ]
|
||
|
then
|
||
|
nmcli con up id "$VPN"
|
||
|
notify-send "connected to $VPN"
|
||
|
else
|
||
|
nmcli con down id "$VPN"
|
||
|
notify-send "disconnected from $VPN"
|
||
|
fi
|
||
|
|
||
|
exit 0
|
||
|
|
||
|
|