From 9ba6e3c8f5c5ce643377b328525490c4cd451831 Mon Sep 17 00:00:00 2001 From: Olivia Mackintosh Date: Sat, 13 Aug 2022 21:46:45 +0200 Subject: statusbar: make POSIX compliant --- .local/bin/statusbar | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to '.local/bin/statusbar') diff --git a/.local/bin/statusbar b/.local/bin/statusbar index 9f124a7..950a9e1 100755 --- a/.local/bin/statusbar +++ b/.local/bin/statusbar @@ -2,27 +2,30 @@ print_wifi() { if=wlan0 - while IFS=$': \t' read -r label value - do - case $label in SSID) SSID=$value - ;; - signal) SIGNAL=$value - ;; + while IFS=':' read -r k v + do + label=$(echo "$k"|trim) + value=$(echo "$v"|trim) + case $label in + SSID) SSID=$value + ;; + signal) SIGNAL=$value + ;; esac - done < <(iw "$if" link) - test "$SIGNAL" && echo -e "$SSID $SIGNAL" + done <<-EOT + $(iw "$if" link) + EOT + test "$SIGNAL" && echo "$SSID $SIGNAL" } - - while true do xsetroot -name\ "$(printf "%s %s %s %s%% %s"\ "$(print_wifi)"\ - "`ip -4 -j a show wlan0 | jq -r ".[0].addr_info[0].local"`"\ - "$(($(cat /proc/meminfo|grep MemAvailable | awk '{print $2}')/1024))M"\ - "`