sb-internet: fix wireguard, refactor
This commit is contained in:
parent
caff0c1b89
commit
5a17a4fd66
|
@ -2,27 +2,38 @@
|
|||
|
||||
shift=""
|
||||
|
||||
if ls /sys/class/net/wl* 1>/dev/null 2>&1; then
|
||||
for w in /sys/class/net/wl*/; do
|
||||
percent="$(grep "$(basename "$(dirname "$w/operstate")")" /proc/net/wireless | tr -s ' ' | cut -d ' ' -f3 | tr -dc "[:digit:]")"
|
||||
grep -vxq '0x\(1\|9\)003' "$w/flags" && wifi_icon="" || wifi_icon="$(sed "s/up//;s/down//;s/dormant//" "$w/operstate" | tr -d "[:space:]")"
|
||||
printf "%b" "$shift$wifi_icon $percent"
|
||||
shift=" "
|
||||
done
|
||||
fi
|
||||
# Ethernet
|
||||
for if in /sys/class/net/*; do
|
||||
eval "$(cat "$if/uevent")"
|
||||
[ -z "$DEVTYPE" ] || continue
|
||||
printf "%b" "$shift"
|
||||
shift=" "
|
||||
done
|
||||
|
||||
if ls /sys/class/net/en* 1>/dev/null 2>&1; then
|
||||
for e in /sys/class/net/e*/operstate; do
|
||||
[ "$(cat "$e")" = "up" ] && printf "%b" "$shift"
|
||||
shift=" "
|
||||
done
|
||||
fi
|
||||
# WLAN
|
||||
for if in /sys/class/net/*; do
|
||||
eval "$(cat "$if/uevent")"
|
||||
[ "$DEVTYPE" = "wlan" ] || continue
|
||||
if grep -vxq '0x\(1\|9\)003' "$if/flags"; then
|
||||
wifi_icon=""
|
||||
else
|
||||
case "$(cat "$if/operstate")" in
|
||||
up) wifi_icon="" ;;
|
||||
down) wifi_icon="" ;;
|
||||
dormant) wifi_icon="" ;;
|
||||
esac
|
||||
fi
|
||||
percent="$(grep "$INTERFACE" /proc/net/wireless | tr -s ' ' | cut -d ' ' -f3 | tr -dc "[:digit:]")"
|
||||
printf "%b" "$shift$wifi_icon $percent"
|
||||
shift=" "
|
||||
done
|
||||
|
||||
if ls /sys/class/net/wg* 1>/dev/null 2>&1; then
|
||||
for _ in /sys/class/net/wg*/carrier; do
|
||||
printf "%b" "$shift"
|
||||
shift=" "
|
||||
done
|
||||
fi
|
||||
# Wireguard
|
||||
for if in /sys/class/net/*; do
|
||||
eval "$(cat "$if/uevent")"
|
||||
[ "$DEVTYPE" = "wireguard" ] || continue
|
||||
printf "%b" "$shift"
|
||||
shift=" "
|
||||
done
|
||||
|
||||
printf "\n"
|
||||
|
|
Loading…
Reference in New Issue