dotfiles/scripts/cava.sh

32 lines
496 B
Bash
Raw Normal View History

2024-05-24 00:20:58 +02:00
#! /bin/sh
bar="▁▂▃▄▅▆▇█"
dict="s/;//g;"
# creating "dictionary" to replace char with bar
i=0
while [ $i -lt ${#bar} ]
do
dict="${dict}s/$i/${bar:$i:1}/g;"
i=$((i=i+1))
done
# write cava config
config_file="/tmp/polybar_cava_config"
echo "
[general]
bars = 30
[output]
method = raw
raw_target = /dev/stdout
data_format = ascii
ascii_max_range = 7
" > $config_file
# read stdout from cava
cava -p $config_file | while read -r line; do
echo $line | sed $dict
done