aboutsummaryrefslogtreecommitdiff
path: root/dotfiles/.local/bin/togglevpn
blob: f1a6bdba746d7e0bc6d0a7b1c9ab47099fde38ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/sh

if [ -f "$HOME/.cache/openvpnpid" ]; then
  sudo killall -SIGINT openvpn
  exit
fi

sudo openvpn "$HOME/.config/ovpn/conf.ovpn" &
PID=$!
notify-send "🔐 OpenVPN" "VPN is being initialized"
echo $PID > ~/.cache/openvpnpid
killall -40 waybar
wait $PID
notify-send "🔐 OpenVPN" "VPN service has stopped with exit code $?"
rm ~/.cache/openvpnpid
killall -40 waybar