scripts/rofi/rofi-openvpn.sh

33 lines
1.3 KiB
Bash
Raw Permalink Normal View History

2020-09-11 15:00:39 +00:00
#!/bin/bash
# Passwordless sudo required
res=$(echo "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
2024-03-08 19:00:51 +00:00
# First option is disabled in favour of nm-applet
if [[ $res = "Connection" ]]; then
2023-01-06 19:41:31 +00:00
/usr/bin/uxterm -e 'sudo /usr/bin/nmtui'
2024-03-08 19:00:51 +00:00
elif [[ $res = "John.Me.tz" ]]; then
2023-01-06 19:41:31 +00:00
sudo /usr/bin/systemctl stop openvpn-client@mailcleaner
2023-10-19 18:39:51 +00:00
/usr/bin/systemctl --user restart wg-quick@wg0
2024-03-08 19:00:51 +00:00
elif [[ $res = "MailCleaner" ]]; then
2023-10-19 18:39:51 +00:00
/usr/bin/systemctl --user stop wg-quick@wg0
2023-01-06 19:41:31 +00:00
sudo /usr/bin/systemctl restart openvpn-client@mailcleaner
2024-03-08 19:00:51 +00:00
elif [[ $res = "Disconnect" ]]; then
2023-01-06 19:41:31 +00:00
sudo /usr/bin/systemctl stop openvpn-client@mailcleaner
2023-10-19 18:39:51 +00:00
/usr/bin/systemctl --user stop wg-quick@wg0
2024-03-08 19:00:51 +00:00
elif [[ $res = "Restart" ]]; then
if [[ "`ip addr show wg0 2> /dev/null`" != "" ]]; then
2023-10-19 18:39:51 +00:00
/usr/bin/systemctl --user restart wg-quick@wg0
2023-01-06 19:41:31 +00:00
fi
2024-03-08 19:00:51 +00:00
if [[ "`ip addr show tun0 2> /dev/null`" != "" ]]; then
2023-01-06 19:41:31 +00:00
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