2020-09-11 15:00:39 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Passwordless sudo required
|
|
|
|
|
2024-03-08 19:00:08 +00:00
|
|
|
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
|
2020-11-16 04:46:04 +00:00
|
|
|
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
|
2021-12-31 16:08:28 +00:00
|
|
|
#/home/jpm/scripts/sway/displays.pl -w
|