2023-08-06 23:01:18 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
get_ssid() {
|
|
|
|
if nmcli -t -f NAME c show --active | grep -v lo; then
|
|
|
|
true
|
|
|
|
else
|
|
|
|
echo "Disconnected"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2023-08-07 20:37:41 -04:00
|
|
|
get_state() {
|
|
|
|
if [[ "$(rfkill list | grep -A 1 LAN | grep -o no)" == "no" ]]; then
|
2023-08-20 00:01:31 -04:00
|
|
|
eww update network_icon=" "
|
2023-08-07 20:37:41 -04:00
|
|
|
else
|
2023-08-20 00:01:31 -04:00
|
|
|
eww update network_icon=" "
|
2023-08-07 20:37:41 -04:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2023-08-06 23:01:18 -04:00
|
|
|
[[ "$1" == "ssid" ]] && get_ssid
|
2023-08-20 00:01:31 -04:00
|
|
|
|
|
|
|
if [[ "$1" == "toggle" ]]; then
|
|
|
|
rfkill toggle wlan
|
|
|
|
get_state
|
|
|
|
fi
|
2023-08-07 20:37:41 -04:00
|
|
|
|
|
|
|
if [[ $1 == "icon" ]]; then
|
|
|
|
while true; do
|
|
|
|
get_state
|
2023-08-20 11:44:31 -04:00
|
|
|
sleep 1
|
2023-08-07 20:37:41 -04:00
|
|
|
done
|
|
|
|
fi
|
2023-08-07 21:07:42 -04:00
|
|
|
|
|
|
|
radio_status () {
|
|
|
|
radio_status=$(nmcli radio wifi)
|
|
|
|
if [[ $radio_status == "enabled" ]]; then
|
|
|
|
echo "on"
|
|
|
|
else
|
|
|
|
echo "off"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
if [[ $1 == "radio-status" ]]; then
|
|
|
|
radio_status
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $1 == "toggle-radio" ]]; then
|
|
|
|
stat=$(radio_status)
|
|
|
|
if [[ $stat == "on" ]]; then
|
|
|
|
nmcli radio wifi off
|
|
|
|
else
|
|
|
|
nmcli radio wifi on
|
|
|
|
fi
|
|
|
|
fi
|