#!/bin/bash

wifi_status=$(nmcli -t -f STATE g)
wifi_essid=$(nmcli -t -f NAME c show --active | head -n1)
wifi_strength=$(awk 'NR==3 {print int($3 * 10/7)}' /proc/net/wireless)

get_wifi_icon() {
    if [[ $wifi_status == "connected" ]]; then
        case $wifi_strength in
        [0-9] | 1[0-9] | 2[0-5]) echo "󰤟" ;;
        2[6-9] | 3[0-9] | 4[0-9] | 50) echo "󰤢" ;;
        5[1-9] | 6[0-9] | 7[0-5]) echo "󰤥" ;;
        *) echo "󰤨" ;;
        esac
    else
        echo "󰤭"
    fi

}

case "$1" in
--COL) echo "$color" ;;
--ESSID) echo $wifi_essid ;;
--ICON) get_wifi_icon ;;
esac
