dotfiles/.local/bin/vpn
2025-01-30 13:55:36 +00:00

27 lines
470 B
Bash
Executable File

#!/bin/bash -e
if tty -s; then
DMENU=fzf
SUDO=sudo
else
DMENU=/usr/local/bin/dmenu
SUDO=pkexec
fi
if [ "$EUID" != 0 ]; then
exec "$SUDO" env DISPLAY="$DISPLAY" XAUTHORITY="$XAUTHORITY" \
"$BASH" -- "${BASH_SOURCE[0]}" "$@"
fi
if [ -z "$1" ]; then
set -- "$(basename -s.conf /etc/wireguard/*.conf | "$DMENU")"
fi
while read -r i; do
wg-quick down "$i"
done < <(wg show interfaces)
if [ "$1" != off ]; then
wg-quick up "$1"
fi