irongit
hygoland/scripts/WaybarCava.sh
42 lines1.0 KBBourne Again Shell (bash)
1#!/bin/bash
2# /* ---- ๐Ÿ’ซ https://github.com/JaKooLit ๐Ÿ’ซ ---- */ ##
3# Not my own work. This was added through Github PR. Credit to original author
4
5#----- Optimized bars animation without much CPU usage increase --------
6bar="โ–โ–‚โ–ƒโ–„โ–…โ–†โ–‡โ–ˆ"
7dict="s/;//g"
8
9# Calculate the length of the bar outside the loop
10bar_length=${#bar}
11
12# Create dictionary to replace char with bar
13for ((i = 0; i < bar_length; i++)); do
14 dict+=";s/$i/${bar:$i:1}/g"
15done
16
17# Create cava config
18config_file="/tmp/bar_cava_config"
19cat >"$config_file" <<EOF
20[general]
21# Older systems show significant CPU use with default framerate
22# Setting maximum framerate to 30
23# You can increase the value if you wish
24framerate = 30
25bars = 10
26
27[input]
28method = pulse
29source = auto
30
31[output]
32method = raw
33raw_target = /dev/stdout
34data_format = ascii
35ascii_max_range = 7
36EOF
37
38# Kill cava if it's already running
39pkill -f "cava -p $config_file"
40
41# Read stdout from cava and perform substitution in a single sed command
42cava -p "$config_file" | sed -u "$dict"