From e76d3bd7062938edf9bc060aa0801ca01071dbae Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Sun, 5 Jan 2025 08:57:39 +0300 Subject: [PATCH] Swayscript: Rework networkwidget logic. --- package/swayscript/script/NetworkWidget.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/package/swayscript/script/NetworkWidget.sh b/package/swayscript/script/NetworkWidget.sh index 33fc935..a654fac 100644 --- a/package/swayscript/script/NetworkWidget.sh +++ b/package/swayscript/script/NetworkWidget.sh @@ -6,7 +6,7 @@ function networkwidget() { local _ethernets=($(printf "%s\n" ${_connections[@]} | rg ethernet | sed "s/ .*//")) local _vpns=($(printf "%s\n" ${_connections[@]} | rg vpn | 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 _bt_lowest=100 local icon="󰖩" @@ -27,11 +27,8 @@ function networkwidget() { done if [[ ${_bts} != "" ]]; then + class="bt" icon="󱛃" - - if [[ ${_bt_lowest} -lt 21 ]]; then - class="btlow" - fi fi if [[ ${_vpns} != "" ]]; then @@ -39,11 +36,18 @@ function networkwidget() { icon="󱚿" fi - if [[ ${internet} != "full" ]]; then + if ! $(command -v nmcli); then + class="disabled" + icon="󱚼" + elif [[ ${internet} != "full" ]]; then class="issue" icon="󱚵" fi + if [[ ${_bt_lowest} -lt 21 ]]; then + class="btlow" + fi + for net in ${_vpns[@]}; do networks+=" ${net}\\n" done