storopoli / flakes

NixOS/MacOS Nix Minimalist-Hardened-Privacy-oriented Configs
MIT License
48 stars 5 forks source link

feat(waybar): Mullvad VPN detector #64

Closed storopoli closed 6 months ago

storopoli commented 6 months ago

Add a custom waybar module that detects if you are connected using the Mullvad VPN.

Something like:

"custom/mullvad": {
    "exec": "waybar-mullvad",
    "return-type": "json"
}

And the script:

#!/bin/sh

vpn() {
    if curl -Ls am.i.mullvad.net/json | jq .mullvad_exit_ip; then
        icon=""
        class=on
    else
        icon=""
        class=off
    fi
    printf '{"text": " %s ", "class": "%s"}\n' "$icon" "$class"
}

if grep '^home-' /etc/hostname > /dev/null; then
    while true; do
        vpn
        sleep 5m
    done
fi