feat: remove st
This commit is contained in:
parent
40b8304dce
commit
17b03778ac
31 changed files with 54 additions and 7057 deletions
|
@ -7,20 +7,26 @@ if tty -s; then
|
|||
SUDO=sudo
|
||||
fi
|
||||
|
||||
if [ "$EUID" != 0 ]; then
|
||||
exec "$SUDO" env DISPLAY="$DISPLAY" XAUTHORITY="$XAUTHORITY" \
|
||||
XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR" "$BASH" -- "${BASH_SOURCE[0]}" "$@"
|
||||
fi
|
||||
d="$(mktemp -d)"
|
||||
# shellcheck disable=SC2064
|
||||
trap "rm -rf '$d'" EXIT
|
||||
touch "$d/"{1..2}
|
||||
|
||||
CMD=()
|
||||
while read -r i; do
|
||||
CMD+=("wg-quick down '$i'")
|
||||
done < <(ip -br link show type wireguard | awk '{print $1}')
|
||||
|
||||
if [ "$1" != off ]; then
|
||||
set -- "$(basename -s.conf "/etc/wireguard/$1"*.conf | "$DMENU")"
|
||||
if ! wg | grep -q "$1"; then
|
||||
wg-quick up "$1"
|
||||
fi
|
||||
CMD=(
|
||||
"basename -s.conf '/etc/wireguard/$1'*.conf > '$d/1'"
|
||||
"inotifywait -e close_write '$d/2'"
|
||||
"${CMD[@]}"
|
||||
"wg-quick up \"\$(cat '$d/2')\""
|
||||
)
|
||||
fi
|
||||
|
||||
while read -r i; do
|
||||
wg-quick down "$i"
|
||||
done < <(ip -br link show type wireguard | awk "\$1 != \"$1\"{print \$1}")
|
||||
(inotifywait -e close_write "$d/1"; "$DMENU" < "$d/1" > "$d/2") &
|
||||
"$SUDO" bash -c "${CMD[*]/%/;}"
|
||||
|
||||
touch "$XDG_RUNTIME_DIR/sbar/vpn"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue