Files
dots/config/polybar/scripts/cava.sh
2025-11-24 19:46:30 +07:00

30 lines
495 B
Bash
Executable File

#! /bin/bash
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 = 10
[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