diff --git a/.config/xfce4/panel/scripts/netstatus.sh b/.config/xfce4/panel/scripts/netstatus.sh index e6eccb6..8ef7cd0 100755 --- a/.config/xfce4/panel/scripts/netstatus.sh +++ b/.config/xfce4/panel/scripts/netstatus.sh @@ -8,15 +8,12 @@ function doPing () { sed 's/.*time=\([0-9\.]*\).*/'"$2"':\1ms/' } -if [[ "$@" -ne "" ]] -then - interfaces=$(ip -4 -o a | grep "$@") -else - interfaces=$(ip -4 -o a) -fi -ip=$(echo "$interfaces" | \ - sed 's/^[0-9]*: \([^ ]*\) inet \([0-9.]*\).*/\1:\2/g' | \ - grep -v lo | \ - tr '\n' ' ') +function get_ip_addresses() { + ip -4 -json address | jq -r ' +map(select(.ifname != "lo") | + .ifname + ":" + (.addr_info | map(.local) | join(","))) | + join(" ") +' +} -echo -n "${ip}$(doPing 8.8.8.8 G)" +echo -n "$(get_ip_addresses) $(doPing 8.8.8.8 G)"