Browse Source

Merge pull request #110 from SherLock707/SherLock707

Added custom Cava based music visualiser for Waybar
pull/112/head
Ja.KooLit 2 years ago committed by GitHub
parent
commit
ce6bcd4284
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 59
      config/hypr/scripts/waybar_cava.sh
  2. 2
      config/waybar/configs/[TOP] Default
  3. 5
      config/waybar/modules
  4. 1
      config/waybar/style/Rose Pine.css

59
config/hypr/scripts/waybar_cava.sh

@ -0,0 +1,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"

2
config/waybar/configs/[TOP] Default

@ -25,6 +25,8 @@
"memory",
"custom/separator#dot-line",
"custom/weather",
"custom/separator#dot-line",
"custom/mviz",
],
"modules-center": [

5
config/waybar/modules

@ -574,6 +574,11 @@
"interval" : 86400, // once every day
"tooltip": true,
},
"custom/mviz": {
"exec": "~/.config/hypr/scripts/waybar_cava.sh",
"format": "{}"
},
// NOTE:! This is only for Arch and Arch Based Distros
"custom/updater":{

1
config/waybar/style/Rose Pine.css

@ -129,6 +129,7 @@ tooltip {
#custom-swaync,
#custom-updater,
#custom-swaync,
#custom-mviz,
#custom-weather,
#custom-weather.clearNight,
#custom-weather.cloudyFoggyDay,

Loading…
Cancel
Save