diff --git a/polybar/.config/polybar/bin/wireguard-status b/polybar/.config/polybar/bin/wireguard-status index 1b35d04..dfa055e 100755 --- a/polybar/.config/polybar/bin/wireguard-status +++ b/polybar/.config/polybar/bin/wireguard-status @@ -1,21 +1,12 @@ #!/usr/bin/env bash -interfaces="$(sudo wg show | grep interface | awk -F ' ' '{print $2}')" +updown="$(sudo wg show $1 2> /dev/null)" -interfaces=(${interfaces// / }) - -# Make sure to toggle spaces between interfaces for legibility -spaceToggle= -space= - -for interface in "${interfaces[@]}" -do - if [ ! $spaceToggle ]; then - space="" - spaceToggle=true - else - space=" " - fi +if [ "$updown" ]; then + spaceToggle=true + icon="嬨" +else + icon="" +fi -echo -n "$space"嬨 "$interface" -done +echo "$icon" "$1" diff --git a/polybar/.config/polybar/config b/polybar/.config/polybar/config index 95b5d31..6d76c58 100644 --- a/polybar/.config/polybar/config +++ b/polybar/.config/polybar/config @@ -48,7 +48,7 @@ inherit = bar/base-laptop monitor = ${env:MONITOR:eDP1} modules-left = bspwm -modules-center = battery0 battery1 wlan wireguard bluetooth +modules-center = battery0 battery1 wlan wg0 wg1 bluetooth modules-right = xbacklight volume-laptop memory cpu temperature filesystem docker updates-arch-combined mail reddit github rss weather date tray-position = right @@ -392,7 +392,7 @@ type = custom/script exec = ~/.config/polybar/bin/rsscount click-left = setsid alacritty --class newsboat,newsboat -e /usr/bin/newsboat -click-middle = setsid newsup +click-middle = setsid ~/.local/bin/newsup [module/mail] type = custom/script @@ -420,11 +420,17 @@ tail = true click-left = sh ~/.config/polybar/bin/system-usb-udev --mount & click-right = sh ~/.config/polybar/bin/system-usb-udev --unmount & -[module/wireguard] +[module/wg0] type = custom/script -exec = ~/.config/polybar/bin/wireguard-status +exec = ~/.config/polybar/bin/wireguard-status wg0 ;This doesn't work when run in the background for some reason -click-left = ~/.local/bin/wireguard-switch +click-left = ~/.local/bin/wireguard-switch wg0 + +[module/wg1] +type = custom/script +exec = ~/.config/polybar/bin/wireguard-status wg1 +;This doesn't work when run in the background for some reason +click-left = ~/.local/bin/wireguard-switch wg1 [module/weather] type = custom/script diff --git a/wireguard/.local/bin/wireguard-switch b/wireguard/.local/bin/wireguard-switch index 82e4f95..66b698e 100755 --- a/wireguard/.local/bin/wireguard-switch +++ b/wireguard/.local/bin/wireguard-switch @@ -1,18 +1,19 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash ### # Switch wireguard vpns up/down ### -STATUS="$(nmcli device status | grep -c wg0)" +STATUS="$(nmcli device status | grep -c $1)" case $STATUS in 1) - wg-quick down wg0 - notify-send.py -a wireguard --replaces-process wireguard-status -i network-vpn-offline-symbolic Wireguard "Connection down" & + wg-quick down "$1" + notify-send.py -a wireguard --replaces-process wireguard-status-"$1" -i network-vpn-offline-symbolic "Wireguard $1" "Connection down" & ;; *) - wg-quick up wg0 - notify-send.py -a wireguard --replaces-process wireguard-status -i network-vpn-symbolic Wireguard "Connection up" & + wg-quick up "$1" + notify-send.py -a wireguard --replaces-process wireguard-status-"$1" -i network-vpn-symbolic "Wireguard $1" "Connection up" & ;; esac +