aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/scripts/waybar_cava.sh
blob: 2ecc4d0be3d789e5dc026df62dd605003086c26d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# #! /bin/bash

# --------------------Smooth bars animation with 1-2% increase in CPU usage -------------------
# 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

# --------------------Optimized bars animation with 1-2% increase in CPU usage -------------------
bar="▁▂▃▄▅▆▇█"
dict="s/;//g"

# Calculate the length of the bar outside the loop
bar_length=${#bar}

# Create dictionary to replace char with bar
for ((i = 0; i < bar_length; i++)); do
    dict+=";s/$i/${bar:$i:1}/g"
done

# Create cava config
config_file="/tmp/polybar_cava_config"
cat >"$config_file" <<EOF
[general]
bars = 10

[output]
method = raw
raw_target = /dev/stdout
data_format = ascii
ascii_max_range = 7
EOF

# Read stdout from cava and perform substitution in a single sed command
cava -p "$config_file" | sed -u "$dict"
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage