diff --git a/desktop/.config/waybar/config b/desktop/.config/waybar/config index e0d7ca1..6946a07 100644 --- a/desktop/.config/waybar/config +++ b/desktop/.config/waybar/config @@ -145,7 +145,7 @@ "format": "{} ", }, "river/window": { - "format": " {}", + "format": " {}", "max-length": 70 }, "temperature": { @@ -166,8 +166,11 @@ "interval": 3600 }, "custom/wireguard": { + "format": "{icon}", "format-icons": { - "default": "󰖂" + "default": "", + "pia": "󰖂", + "netbird": "󱗆" }, "exec": "~/.config/waybar/modules/wireguard json", "exec-if": "command -v nmcli >/dev/null 2>&1", diff --git a/desktop/.config/waybar/modules/wireguard b/desktop/.config/waybar/modules/wireguard index fcdca46..db27acf 100755 --- a/desktop/.config/waybar/modules/wireguard +++ b/desktop/.config/waybar/modules/wireguard @@ -41,9 +41,8 @@ connected=() available=() function print_as_json() { - text="󰖂" # only prints a single icon when connected - # text="${1}" # use this line to show all output in text - alt="${1}" + text="${1%% |*}" # prints out name of first vpn it finds + alt="${1%%:*}" tooltip="${1}" [ -n "$1" ] && class="connected" || class="disconnected" printf "{\"text\": \"%s\", \"alt\": \"%s\", \"tooltip\": \"%s\", \"class\": \"%s\"}" \ @@ -79,7 +78,19 @@ function get_pia { status=$(piactl get connectionstate) if [[ $status = "Connected" ]]; then - connected+=("$(piactl get region): $(piactl get vpnip)") + connected+=("pia: $(piactl get vpnip)") + fi +} + +function get_netbird { + if ! command -v netbird >/dev/null 2>&1 || [ "$(systemctl is-active netbird)" == "inactive" ]; then + return 1 + fi + + status="$(netbird status)" + + if echo "$status" | grep -q "^Signal: Connected"; then + connected+=("netbird:$(echo "$status" | grep "^NetBird IP:" | cut -d':' -f2)") fi } @@ -122,19 +133,22 @@ function array_contains { } if [[ $nargs == 0 ]] || [[ $printjson = "yes" ]]; then - get_conns "$wgactive" get_pia + get_netbird + get_conns "$wgactive" print_conns connected elif [[ $showmenu == "yes" ]]; then - get_conns "$wgconns" get_pia + get_netbird + get_conns "$wgconns" print_conns connected "list" print_conns available "list" elif [[ $dotoggle == "yes" ]]; then - get_conns "$wgconns" get_pia + get_netbird + get_conns "$wgconns" if [[ "$(array_contains connected "$conn")" == "yes" ]]; then $nmclicmd down "$conn"