#!/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