#!/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" \ XDG_CACHE_HOME="$XDG_CACHE_HOME" "$BASH" -- "${BASH_SOURCE[0]}" "$@" fi if [ "$1" != off ]; then set -- "$(basename -s.conf "/etc/wireguard/$1"*.conf | "$DMENU")" if ! wg | grep -q "$1"; then wg-quick up "$1" fi fi while read -r i; do wg-quick down "$i" done < <(ip -br link show type wireguard | awk "\$1 != \"$1\"{print \$1}") kill -37 "$(cat "$XDG_CACHE_HOME/sbar/pid")"