Swayscript: Rework networkwidget logic.

This commit is contained in:
Dmitry Voronin 2025-01-05 08:57:39 +03:00
parent 247f716398
commit e76d3bd706
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k

View file

@ -6,7 +6,7 @@ function networkwidget() {
local _ethernets=($(printf "%s\n" ${_connections[@]} | rg ethernet | sed "s/ .*//")) local _ethernets=($(printf "%s\n" ${_connections[@]} | rg ethernet | sed "s/ .*//"))
local _vpns=($(printf "%s\n" ${_connections[@]} | rg vpn | sed "s/ .*//")) local _vpns=($(printf "%s\n" ${_connections[@]} | rg vpn | sed "s/ .*//"))
local _wifis=($(printf "%s\n" ${_connections[@]} | rg wifi | sed "s/ .*//")) local _wifis=($(printf "%s\n" ${_connections[@]} | rg wifi | sed "s/ .*//"))
local _bts_raw=($(bluetoothctl devices Connected)) local _bts_raw=($(timeout 2 bluetoothctl devices Connected)) # HACK: Sometimes it hangs, thus a timeout.
local _bts=() local _bts=()
local _bt_lowest=100 local _bt_lowest=100
local icon="󰖩" local icon="󰖩"
@ -27,11 +27,8 @@ function networkwidget() {
done done
if [[ ${_bts} != "" ]]; then if [[ ${_bts} != "" ]]; then
class="bt"
icon="󱛃" icon="󱛃"
if [[ ${_bt_lowest} -lt 21 ]]; then
class="btlow"
fi
fi fi
if [[ ${_vpns} != "" ]]; then if [[ ${_vpns} != "" ]]; then
@ -39,11 +36,18 @@ function networkwidget() {
icon="󱚿" icon="󱚿"
fi fi
if [[ ${internet} != "full" ]]; then if ! $(command -v nmcli); then
class="disabled"
icon="󱚼"
elif [[ ${internet} != "full" ]]; then
class="issue" class="issue"
icon="󱚵" icon="󱚵"
fi fi
if [[ ${_bt_lowest} -lt 21 ]]; then
class="btlow"
fi
for net in ${_vpns[@]}; do for net in ${_vpns[@]}; do
networks+="${net}\\n" networks+="${net}\\n"
done done