1
0
Fork 0
dotfiles/.local/libexec/statusbar/sb-internet

29 lines
796 B
Plaintext
Raw Normal View History

2022-07-04 21:36:33 +02:00
#!/bin/sh
2022-09-27 10:47:14 +02:00
2024-02-03 17:52:33 +01:00
shift=""
2022-09-27 10:47:14 +02:00
if ls /sys/class/net/w*/operstate 1>/dev/null 2>&1; then
2023-02-07 17:19:53 +01:00
for w in /sys/class/net/w*/; do
2024-02-03 17:52:33 +01:00
percent="$(grep "$(basename "$(dirname "$w/operstate")")" /proc/net/wireless | tr -s ' ' | cut -d ' ' -f3 | tr -dc "[:digit:]")"
grep -vxq '0x1003' "$w/flags" && wifi_icon="" || wifi_icon="$(sed "s/up/󰖩/;s/down/󰖪/;s/dormant/󰤯/" "$w/operstate" | tr -d "[:space:]")"
2024-02-03 18:21:24 +01:00
printf "%b" "$shift$wifi_icon $percent"
2023-02-07 17:19:53 +01:00
shift=" "
done
2022-07-04 21:36:33 +02:00
fi
2022-09-15 20:27:44 +02:00
2022-09-27 10:47:14 +02:00
if ls /sys/class/net/e*/operstate 1>/dev/null 2>&1; then
2023-02-07 17:19:53 +01:00
for e in /sys/class/net/e*/operstate; do
2024-01-15 22:25:14 +01:00
[ "$(cat "$e")" = "up" ] && printf "%b" "$shift󰈁"
2023-02-07 17:19:53 +01:00
shift=" "
done
2022-09-27 10:47:14 +02:00
fi
2022-09-17 02:39:38 +02:00
2022-09-27 10:47:14 +02:00
if ls /sys/class/net/tun*/operstate 1>/dev/null 2>&1; then
2023-02-07 17:19:53 +01:00
for _ in /sys/class/net/tun*/operstate; do
2024-02-03 18:21:24 +01:00
printf "%b" "$shift󰖂"
2023-02-07 17:19:53 +01:00
shift=" "
done
2022-09-27 10:47:14 +02:00
fi
2022-09-15 20:27:44 +02:00
2023-11-21 14:34:46 +01:00
printf "\n"