#! /bin/zsh # use once: # # a-level t # # continous: invoke with signal USR1; # terminate with C-c C-c # # a-level # kill -s USR1 PID # should be faster than 300 ms do-a-level () { (($#)) || (($+AUDIO_OUTPUT)) || set /dev/stdout rec --null stat trim 0 0.1 2>&1 | \ grep 'Maximum amplitude' | \ cut -d' ' -f 7 >> $1 } trap 'do-a-level' USR1 (($+1)) && do-a-level || while ((1)) {}