diff --git a/modules/home/waybar/scripts.nix b/modules/home/waybar/scripts.nix index 4932a4d..aea4c1a 100644 --- a/modules/home/waybar/scripts.nix +++ b/modules/home/waybar/scripts.nix @@ -1,5 +1,7 @@ { pkgs, username, ... }: - +let + externalIPv4 = ""; +in { home.file = { "/home/${username}/.local/bin/waybar-yubikey" = { @@ -213,6 +215,7 @@ ''; }; "/home/${username}/.local/bin/waybar-vpn" = { + # unused nowadays executable = true; text = '' #!/usr/bin/env bash @@ -222,6 +225,23 @@ || echo '{"text":"Disconnected","class":"disconnected","percentage":0}' ''; }; + "/home/${username}/.local/bin/waybar-mullvad" = { + executable = true; + text = '' + #!/usr/bin/env bash + + STATUS="$(mullvad status | grep -Eio 'connected|connecting|disconnected' | tr '[:upper:]' '[:lower:]')" + NODE="$(mullvad status | grep -Ei 'relay' | awk '{print $2}' | tr '[:upper:]' '[:lower:]')" + LOCATION="$(mullvad status | grep -Ei 'location' | cut -d':' -f2 | cut -d'.' -f1 | sed 's/ //g')" + IPV4="$(mullvad status | grep 'IPv4' | cut -d':' -f3 | sed 's/ //g')" + echo "$IPV4" | grep -q "${externalIPv4}" && LOCATION="home" + + echo "$STATUS" | grep -Eioq 'connected|connecting' && TEXT="{\"text\":\"$STATUS ($LOCATION)\",\"location\":\"$LOCATION\",\"node\":\"$NODE\"}" || ip address show tailscale0 | grep "global tailscale0" -q && TEXT="{\"text\":\"tailscale ($LOCATION)\",\"location\":\"$LOCATION\",\"node\":\"$NODE\"}" + echo "$STATUS" | grep -Eioq 'disconnected' && TEXT="{\"text\":\"$STATUS\",\"location\":\"$LOCATION\",\"node\":\"$NODE\"}" + + echo "$TEXT" + ''; + }; }; home.packages = with pkgs; [ wf-recorder