aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dot_config/waybar/executable_wg-status.sh
blob: 1fd7241cc056ea9c62bc3689d33239effb930fc3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/bin/sh
# Emit waybar JSON describing wireguard status. Uses `ip` (no root needed).
set -eu

iface=$(ip -br link show type wireguard 2>/dev/null | awk 'NF{print $1; exit}')

if [ -n "${iface:-}" ]; then
  printf '{"text":"WG %s","class":"up","tooltip":"%s"}\n' \
    "$iface" \
    "$(ip -br -4 addr show dev "$iface" 2>/dev/null | awk '{for(i=3;i<=NF;i++)printf "%s ",$i}')"
else
  printf '{"text":"WG off","class":"down","tooltip":"no wireguard interface"}\n'
fi