fix script for toggling vpn

This commit is contained in:
Tyler Starr 2023-10-07 21:47:35 -07:00
parent 07ef08868d
commit ac95f2128f
5 changed files with 12 additions and 27 deletions

View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
if [ -f ~/.wg0 ]; then
sudo systemctl stop wg-quick-wg0.service
rm ~/.wg0
else
sudo systemctl restart wg-quick-wg0.service
touch ~/.wg0
fi

View File

@ -127,7 +127,6 @@ mode utility {
bindsym q exit
bindsym r reload
bindsym g exec "~/.config/sway/scripts/gamemode.sh", $e
bindsym v exec "~/.config/sway/scripts/toggle-vpn.sh {{ .hostname }}", $e
bindsym Escape mode default
}

View File

@ -44,11 +44,11 @@ txmb=$(echo "scale = 1; $tx / 1280000" | bc | awk '{printf "%05.1f\n", $0}')
rxmb=$(echo "scale = 1; $rx / 1280000" | bc | awk '{printf "%05.1f\n", $0}')
# Vpn status
vpn=$(nmcli c show --active | grep wireguard | cut -d ' ' -f1)
if $vpn ; then
if [ -f ~/.wg0 ] ; then
vpn="wg0"
else
vpn="none"
fi
#<span foreground='#c16b26'>lel</span>
echo -e "👍 $txmb 👎 $rxmb | 📡 $vpn | ⬆️ $uptime_formatted | 🔉<span foreground='$volume_color'>$volume%</span> | $gamemode | 🐧 $linux_version | $date_formatted "

View File

@ -1,8 +0,0 @@
#!/usr/bin/env bash
cons=$(nmcli -t -f NAME c show --active | grep $1)
if [ $cons ]; then
nmcli c down $1 1> /dev/null
else
nmcli c up $1 1> /dev/null
fi

View File

@ -59,21 +59,6 @@
extraGroups = [ "dialout" "wheel" "docker" "libvirtd" ]; # Enable sudo for the user.
};
# Allow users to start/stop wireguard vpn
security.sudo.extraRules = [{
commands = [
{
command = "${pkgs.systemc}/bin/systemctl restart wg-quick-wg0";
options = [ "NOPASSWD" ];
}
{
command = "${pkgs.systemc}/bin/systemctl stop wg-quick-wg0";
options = [ "NOPASSWD" ];
}
];
groups = [ "wheel" ];
}];
# List packages installed in system profile.
environment.systemPackages = with pkgs; [
# One-off stable packages