feat: adds mullvad script

This commit is contained in:
Ahwx 2025-12-01 14:30:02 +01:00
parent eecc50d44e
commit c8c1276199

View file

@ -1,5 +1,7 @@
{ pkgs, username, ... }: { pkgs, username, ... }:
let
externalIPv4 = "";
in
{ {
home.file = { home.file = {
"/home/${username}/.local/bin/waybar-yubikey" = { "/home/${username}/.local/bin/waybar-yubikey" = {
@ -213,6 +215,7 @@
''; '';
}; };
"/home/${username}/.local/bin/waybar-vpn" = { "/home/${username}/.local/bin/waybar-vpn" = {
# unused nowadays
executable = true; executable = true;
text = '' text = ''
#!/usr/bin/env bash #!/usr/bin/env bash
@ -222,6 +225,23 @@
|| echo '{"text":"Disconnected","class":"disconnected","percentage":0}' || 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; [ home.packages = with pkgs; [
wf-recorder wf-recorder