Here is simple.sh
#!/bin/bash
sum=0
count=0
test() {
if [ $count -gt 10 ]
then
sum=$[sum+1]
count=0
fi
echo "Sum= "$sum" | "$count
}
while true; do
echo "%{c} $(test)"
count=$[count+1]
sleep 1
done
I then pipe this to lemonbar. The code initially works but when the if clause comes into being count is set to zero and stays at zero (why?), so the sum is not updated after another 10 secs. How can I alter this?