0

I'm writing a bar script and I don't want to check WiFi's ssid and it's state every 20/30 seconds when I know that it won't change for a while. I would like to use something like bspc's command subscribe report which updates only if there is a change.

Here is what I have for context:

while : do case "con=$(cat /sys/class/net/w*/operstate 2>/dev/null)" in [Dd]*) ssid='No Connection' ;; [Uu]*) ssid=$(iwgetid -r) ;; esac echo "$ssid" sleep 30 done 

1 Answer 1

0

I probably did a terrible job at explaining what I want the script to actually do, so here is a better version:

I don't want to refresh the bar every 20/30 seconds just to display the same ssid every time, I only want to refresh it if there is a different output from the script.

I did find a solution by total accident:

# This function checks if the line is actually different or not, # it's stolen from herbstluftwm example script uniq_linebuffered() { awk -W interactive '$0 != l { print ; l=$0 ; fflush(); }' "$@" } while : do case "con=$(cat /sys/class/net/w*/operstate 2>/dev/null)" in [Dd]*) ssid='No Connection' ;; [Uu]*) ssid=$(iwgetid -r) ;; esac echo "$ssid" sleep 10 || break done > >(uniq_linebuffered) & 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.