scripts/rofi/rofi-openvpn.sh

32 lines
1.3 KiB
Bash
Raw Normal View History

2020-09-11 15:00:39 +00:00
#!/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)
2020-09-11 15:00:39 +00:00
if [ $res = "Connection" ]; then
2023-01-06 19:41:31 +00:00
/usr/bin/uxterm -e 'sudo /usr/bin/nmtui'
2020-09-11 15:00:39 +00:00
elif [ $res = "John.Me.tz" ]; then
2023-01-06 19:41:31 +00:00
sudo /usr/bin/systemctl stop openvpn-client@mailcleaner
sudo /usr/bin/systemctl restart wg-quick@wg0
2020-09-11 15:00:39 +00:00
elif [ $res = "MailCleaner" ]; then
2023-01-06 19:41:31 +00:00
sudo /usr/bin/systemctl stop wg-quick@wg0
sudo /usr/bin/systemctl restart openvpn-client@mailcleaner
2020-09-11 15:00:39 +00:00
elif [ $res = "Disconnect" ]; then
2023-01-06 19:41:31 +00:00
sudo /usr/bin/systemctl stop openvpn-client@mailcleaner
sudo /usr/bin/systemctl stop wg-quick@wg0
2020-09-11 15:00:39 +00:00
elif [ $res = "Restart" ]; then
2023-01-06 19:41:31 +00:00
if [ "`ip addr show wg0 2> /dev/null`" != "" ]; then
sudo /usr/bin/systemctl restart wg-quick@wg0
fi
if [ "`ip addr show tun0 2> /dev/null`" != "" ]; then
sudo /usr/bin/systemctl restart openvpn-client@mailcleaner
fi
else
2023-01-06 19:41:31 +00:00
exit
2020-09-11 15:00:39 +00:00
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