diff options
| author | Ja.KooLit <jimmielovejay@gmail.com> | 2024-01-02 01:21:53 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-02 01:21:53 +0900 |
| commit | 1acea95602ecd292f4c806ce946c0ab33176e4ce (patch) | |
| tree | a43d4ccfd313a4effa92919fef8d96934c23bac8 /config/hypr/scripts/WaybarCava.sh | |
| parent | 3d0283f6c0f323bf504d99aadb0019e6357048a8 (diff) | |
| parent | e2bcb89ce79d0a0469e3eb362cc0cc802ddac208 (diff) | |
Merge pull request #116 from JaKooLit/development
Development
Diffstat (limited to 'config/hypr/scripts/WaybarCava.sh')
| -rwxr-xr-x | config/hypr/scripts/WaybarCava.sh | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/config/hypr/scripts/WaybarCava.sh b/config/hypr/scripts/WaybarCava.sh new file mode 100755 index 00000000..77fce82a --- /dev/null +++ b/config/hypr/scripts/WaybarCava.sh @@ -0,0 +1,32 @@ +# #! /bin/bash +## /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## + +# Not my own work. This was added through Github PR. Credit to original author + +#----- Optimized bars animation without much CPU usage increase -------- +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/bar_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" |
