#!/bin/bash if=$(ip -j r list default | jq -r '.[0].dev') if [[ "$if" != "null" ]]; then type="$(nmcli -t -g general.type device show $if)" ip4="$(nmcli -t -g ip4.address device show $if)" ip6="$(nmcli -t -g ip6.address device show $if | sed 's/\\//g')" if [[ "$type" == "wifi" ]]; then icon="󰖩" name="$(nmcli -t -g general.connection device show $if)" rate="$(nmcli -t -g 'AP' device show wlo1 | awk -F ':' '{if ($2 == "*") { print $12 } }')" signal="$(nmcli -t -g 'AP' device show wlo1 | awk -F ':' '{if ($2 == "*") { print $13 } }')%" else icon="󰛳" name="Ethernet" fi else icon="󰲛" name="Not connected" fi cat << EOF {"if": "$if", "icon": "$icon", "type": "$type", "name": "$name", "ip4": "$ip4", "ip6": "$ip6", "rate": "$rate", "signal": "$signal"} EOF