nixos/home/hyprland/ironbar/reference/scripts/wifi

27 lines
573 B
Plaintext
Raw Normal View History

2023-10-10 20:00:04 +01:00
#!/usr/bin/env bash
status=$(nmcli g | tail -n 1 | awk '{print $1}')
signal=$(nmcli -t -f in-use,signal device wifi list | rg "\*" | cut -d: -f2)
essid=$(nmcli -t -f in-use,ssid dev wifi | rg "\*" | cut -d: -f2)
icons=("󰤯" "󰤟" "󰤢" "󰤥" "󰤨")
if [ "$status" = "disconnected" ]; then
icon=""
color="#988ba2"
else
level=$(awk -v n="$signal" 'BEGIN{print int(n/20)}')
if [ "$level" -gt 4 ]; then
level=4
fi
icon=${icons[$level]}
color="#cba6f7"
fi
case $1 in
--COL) echo $color ;;
--ESSID) echo $essid ;;
--ICON) echo $icon ;;
esac