#!/bin/bash
#
#  If your spectrum conky does not show any bar movement,
#  use this script to test if there is a cava data stream.
#  There should be a stream of numbers flowing over your
#  screen! If they are all zero's or all numbers stay the
#  same then there is something wrong with the cava setup.
#

source "./settings.ini"

FILE="$cavaout/cava-output"
DATA="$cavaout/stream-test"

function stream() {
while :
do
    TIME1=$(stat -c '%y' $FILE)
    sleep 0.5
    TIME2=$(stat -c '%y' $FILE)
    if [ "$TIME1" = "$TIME2" ]; then
      rm -f $DATA
    else
      touch $DATA
    fi
done
}
stream &


while true
do
    if [ -f "$DATA" ]; then
      cat $cavaout/cava-output
      sleep .03
    else
      echo -e "\e[31;1m$cavaout/cava-output is not updated with new data!\e[m"
      sleep 1
    fi
done
