diff --git a/dotfiles/.local/bin/vpn-notify b/dotfiles/.local/bin/vpn-notify
index 8efd194..32e7cdc 100755
--- a/dotfiles/.local/bin/vpn-notify
+++ b/dotfiles/.local/bin/vpn-notify
@@ -13,6 +13,11 @@ RETRIES=5
ICON_ON=/usr/share/icons/hicolor/scalable/apps/nm-vpn-active-lock-symbolic.svg
ICON_OFF=/usr/share/icons/hicolor/scalable/apps/nm-vpn-standalone-lock-symbolic.svg
+# Provider logos: Papirus has Mullvad's and Proton's; Tailscale's and UniFi's
+# live in this repo (.local/share/vpn-notify).
+PAPIRUS_APPS=/usr/share/icons/Papirus/64x64/apps
+LOCAL_ICONS=$HOME/.local/share/vpn-notify
+
# Friendly name for an interface: NetworkManager connection name if it has one
vpn_name() {
local name
@@ -20,6 +25,19 @@ vpn_name() {
echo "${name:-$1}"
}
+# Logo for a VPN by its name (as vpn_name/active_vpns give it), or $2 if
+# it's not one of the known providers or the logo is missing
+vpn_icon() {
+ local icon
+ case "${1,,}" in
+ *mullvad*) icon=$PAPIRUS_APPS/mullvad-vpn.svg ;;
+ *proton*) icon=$PAPIRUS_APPS/protonvpn-logo.svg ;;
+ tailscale) icon=$LOCAL_ICONS/tailscale.svg ;;
+ *unifi*) icon=$LOCAL_ICONS/unifi.svg ;;
+ esac
+ [[ -n $icon && -f $icon ]] && echo "$icon" || echo "$2"
+}
+
active_vpns() {
ip -d -o link show up 2>/dev/null \
| awk -F': ' '/ (wireguard|tun) / { sub(/@.*/, "", $2); print $2 }' \
@@ -71,14 +89,14 @@ reconnect() {
for ((attempt = 1; attempt <= RETRIES; attempt++)); do
nmcli connection down "$uuid" >/dev/null 2>&1
if nmcli -w 20 connection up "$uuid" >/dev/null 2>&1 && sleep 2 && tunnel_works "$uuid"; then
- notify "π VPN reconnected" "$ICON_ON" \
+ notify "π VPN reconnected" "$(vpn_icon "$name" "$ICON_ON")" \
"β$nameβ was reconnected after switching to β$(current_network_name)β."
return 0
fi
sleep $((attempt * 3))
done
- notify "β οΈ VPN reconnect failed" "$ICON_OFF" \
+ notify "β οΈ VPN reconnect failed" "$(vpn_icon "$name" "$ICON_OFF")" \
"Couldn't reconnect β$nameβ after $RETRIES attempts." -u critical
return 1
}
@@ -123,11 +141,11 @@ while sleep "$INTERVAL"; do
[[ $cur == "$prev" ]] && continue
while read -r vpn; do
- [[ -n $vpn ]] && notify "π VPN connected" "$ICON_ON" "You are now connected to β$vpnβ."
+ [[ -n $vpn ]] && notify "π VPN connected" "$(vpn_icon "$vpn" "$ICON_ON")" "You are now connected to β$vpnβ."
done < <(comm -13 <(echo "$prev") <(echo "$cur"))
while read -r vpn; do
- [[ -n $vpn ]] && notify "π VPN disconnected" "$ICON_OFF" "β$vpnβ has been disconnected."
+ [[ -n $vpn ]] && notify "π VPN disconnected" "$(vpn_icon "$vpn" "$ICON_OFF")" "β$vpnβ has been disconnected."
done < <(comm -23 <(echo "$prev") <(echo "$cur"))
prev=$cur
diff --git a/dotfiles/.local/share/vpn-notify/tailscale.svg b/dotfiles/.local/share/vpn-notify/tailscale.svg
new file mode 100644
index 0000000..281b859
--- /dev/null
+++ b/dotfiles/.local/share/vpn-notify/tailscale.svg
@@ -0,0 +1,16 @@
+
diff --git a/dotfiles/.local/share/vpn-notify/unifi.svg b/dotfiles/.local/share/vpn-notify/unifi.svg
new file mode 100644
index 0000000..3f3ef02
--- /dev/null
+++ b/dotfiles/.local/share/vpn-notify/unifi.svg
@@ -0,0 +1,7 @@
+