scripts/rofi/rofi-openvpn.sh

32 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# Passwordless sudo required
res=$(echo "Connection|John.Me.tz|MailCleaner|Disconnect|Restart" | rofi -sep "|" -dmenu -i -p 'P ' "" -columns 9 -width 45 -l 1 -config /home/jpm/.config/rofi/config.rasi -theme /home/jpm/.config/rofi/sidebar -hide-scrollbar -eh 1 -location 0 -auto-select -no-fullscreen)
if [ $res = "Connection" ]; then
/usr/bin/uxterm -e 'sudo /usr/bin/nmtui'
elif [ $res = "John.Me.tz" ]; then
sudo /usr/bin/systemctl stop openvpn-client@mailcleaner
/usr/bin/systemctl --user restart wg-quick@wg0
elif [ $res = "MailCleaner" ]; then
/usr/bin/systemctl --user stop wg-quick@wg0
sudo /usr/bin/systemctl restart openvpn-client@mailcleaner
elif [ $res = "Disconnect" ]; then
sudo /usr/bin/systemctl stop openvpn-client@mailcleaner
/usr/bin/systemctl --user stop wg-quick@wg0
elif [ $res = "Restart" ]; then
if [ "`ip addr show wg0 2> /dev/null`" != "" ]; then
/usr/bin/systemctl --user restart wg-quick@wg0
fi
if [ "`ip addr show tun0 2> /dev/null`" != "" ]; then
sudo /usr/bin/systemctl restart openvpn-client@mailcleaner
fi
else
exit
fi
# Waybar sometimes doesn't update with the VPN IP, for whatever reason. Restart it.
# exits above because I change outputs more often than I change VPNs
#/home/jpm/scripts/sway/displays.pl -w