mirror of
https://github.com/alrayyes/dotfiles/
synced 2023-11-14 15:56:30 +00:00
split wireguard status into individual widgets
This commit is contained in:
parent
3e153b8976
commit
82550fdc9b
@ -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=""
|
||||
if [ "$updown" ]; then
|
||||
spaceToggle=true
|
||||
else
|
||||
space=" "
|
||||
fi
|
||||
icon="嬨"
|
||||
else
|
||||
icon=""
|
||||
fi
|
||||
|
||||
echo -n "$space"嬨 "$interface"
|
||||
done
|
||||
echo "$icon" "$1"
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user