diff options
Diffstat (limited to 'sh/vpn')
-rwxr-xr-x | sh/vpn | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -0,0 +1,27 @@ +#!/bin/sh +# toggle VPN + +down_not_mydefault () { + for v in wg_studio wg_ia wg_ka; do + nmcli connection down "$v" + done +} + +# no toggle wg_mydefault, I want wg_mydefault to always on by default +if ! [ "$1" ] || [ "$1" = mydefault ]; then + down_not_mydefault + nmcli connection up wg_mydefault + notify-send -u critical 'VPN disabled' + exit +fi + +if nmcli -t --fields device,state device | grep -q "^wg_$1:connected$"; then + down_not_mydefault + nmcli connection up wg_mydefault + notify-send -u critical "$1 VPN disabled" +else + down_not_mydefault + nmcli connection down wg_mydefault + nmcli connection up "wg_$1" + notify-send "$1 VPN enabled" +fi |