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

14 lines
666 B
Text
Raw Normal View History

2022-07-04 21:36:33 +02:00
#!/bin/sh
2022-09-15 20:27:44 +02:00
big="\033[11m"
norm="\033[10m"
2022-07-04 21:36:33 +02:00
if grep -xq 'up' /sys/class/net/w*/operstate 2>/dev/null ; then
2022-09-15 20:27:44 +02:00
percent="$(cat /proc/net/wireless | tail -1 | tr -s ' ' | cut -d ' ' -f3 | sed 's/\.//')"
wifi_icon="直"
2022-07-04 21:36:33 +02:00
elif grep -xq 'down' /sys/class/net/w*/operstate 2>/dev/null ; then
2022-09-15 20:27:44 +02:00
grep -xq '0x1003' /sys/class/net/w*/flags && wifi_icon="睊" || wifi_icon=""
2022-07-04 21:36:33 +02:00
fi
2022-09-15 20:27:44 +02:00
ls /sys/class/net/tun* 1>/dev/null 2>&1 && vpn_icon="$(sed "s/.*/嬨/" /sys/class/net/tun*/operstate 2>/dev/null)" || vpn_icon=""
printf "$big%s$norm %s $big%s%s$norm" "$wifi_icon" " $percent" "$(sed "s/down//;s/up//" /sys/class/net/e*/operstate 2>/dev/null | tr "\n" " " | xargs echo -n)" "$vpn_icon"