Create vpn.sh

This commit is contained in:
FURK4NGG
2026-07-25 14:58:49 +03:00
committed by GitHub
parent 37c69ce308
commit 0bb1fefcbf
+19
View File
@@ -0,0 +1,19 @@
#!/bin/bash
VPN_NAME="wg0"
if nmcli -t -f NAME connection show --active | grep -Fxq "$VPN_NAME"; then
if nmcli connection down "$VPN_NAME"; then
notify-send "VPN" "$VPN_NAME disconnected"
else
notify-send -u critical "VPN Error" "Failed to disconnect $VPN_NAME"
exit 1
fi
else
if nmcli connection up "$VPN_NAME"; then
notify-send "VPN" "$VPN_NAME connected"
else
notify-send -u critical "VPN Error" "Failed to connect $VPN_NAME"
exit 1
fi
fi