29 lines
659 B
Bash
Executable File
29 lines
659 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
while true; do
|
|
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}')
|
|
|
|
icons=("" "" "" "" "")
|
|
|
|
if [ "$status" = "disconnected" ] ; then
|
|
icon=""
|
|
text=""
|
|
color="#988ba2"
|
|
else
|
|
level=$(awk -v n="$signal" 'BEGIN{print int(n/15)}')
|
|
if [ "$level" -gt 4 ]; then
|
|
level=4
|
|
fi
|
|
|
|
icon=${icons[$level]}
|
|
color="#cba6f7"
|
|
fi
|
|
|
|
echo '{ "essid": "'"$essid"'", "icon": "'"$icon"'", "color": "'"$color"'" }'
|
|
|
|
sleep 10
|
|
done |