#!/usr/bin/env bash
# vpn.sh — show the VPN tunnel IP for the Polybar `vpn` module.
# Checks tun0 (OpenVPN, e.g. HTB/THM); falls back to any tun*/wg* iface.
# Glyphs: = connected (shield), = down (broken shield).
for ifc in tun0 $(ls /sys/class/net 2>/dev/null | grep -E '^(tun|wg)' ); do
ip=$(ip -4 addr show "$ifc" 2>/dev/null | awk '/inet /{print $2}' | cut -d/ -f1)
if [ -n "$ip" ]; then
printf ' %s' "$ip"
exit 0
fi
done
printf ' vpn'