scripts/rofi/rofi-openvpn.sh

30 lines
1.0 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 -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@*
sudo /usr/bin/systemctl start openvpn-client@john.me.tz
elif [ $res = "MailCleaner" ]; then
sudo /usr/bin/systemctl stop openvpn-client@*
sudo /usr/bin/systemctl start openvpn-client@mailcleaner
elif [ $res = "Disconnect" ]; then
sudo /usr/bin/systemctl stop openvpn-client@*
elif [ $res = "Restart" ]; then
sudo /usr/bin/systemctl restart openvpn-client@*
fi
exit
# 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
if [ "$(pgrep -c waybar)" -gt 0 ]; then
sleep 2s
pkill waybar
waybar
fi