2022-09-14 15:35:52 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
while true; do
|
2022-09-14 17:58:08 +03:00
|
|
|
info="$(iwctl station wlan0 show)"
|
|
|
|
status=$(echo "$info" | awk 'FNR == 6 {print $2}')
|
|
|
|
_signal=$(echo "$info" | awk 'FNR == 13 {print $2}')
|
|
|
|
signal=${_signal#"-"}
|
|
|
|
essid=$(echo "$info" | awk 'FNR == 7 {print $3}')
|
2022-09-14 15:35:52 +03:00
|
|
|
|
|
|
|
icons=("" "" "" "" "")
|
|
|
|
|
|
|
|
if [ "$status" = "disconnected" ] ; then
|
|
|
|
icon=""
|
|
|
|
text=""
|
|
|
|
color="#988ba2"
|
|
|
|
else
|
2022-09-14 17:58:08 +03:00
|
|
|
level=$(awk -v n="$signal" 'BEGIN{print int(n/15)}')
|
2022-09-14 15:35:52 +03:00
|
|
|
if [ "$level" -gt 4 ]; then
|
|
|
|
level=4
|
|
|
|
fi
|
|
|
|
|
|
|
|
icon=${icons[$level]}
|
|
|
|
color="#cba6f7"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo '{ "essid": "'"$essid"'", "icon": "'"$icon"'", "color": "'"$color"'" }'
|
|
|
|
|
2022-09-14 17:58:08 +03:00
|
|
|
sleep 10
|
2022-09-14 15:35:52 +03:00
|
|
|
done
|