diff options
| author | SherLock707 <kirangeorge1995@gmail.com> | 2023-12-29 14:52:13 +0530 |
|---|---|---|
| committer | SherLock707 <kirangeorge1995@gmail.com> | 2023-12-29 14:52:13 +0530 |
| commit | 8f2104a3a0d0f1c5561917e9ec2dd61622a65926 (patch) | |
| tree | b69281ad02a353d6a98a392a767a9e933a31a785 | |
| parent | 46677e3f5bbc124459c5fa8b84d51ae22c7ad8ae (diff) | |
Added custom cava based music visualizer for waybar
| -rwxr-xr-x | config/hypr/scripts/waybar_cava.sh | 59 | ||||
| -rw-r--r-- | config/waybar/configs/[TOP] Default | 2 | ||||
| -rw-r--r-- | config/waybar/modules | 5 | ||||
| -rw-r--r-- | config/waybar/style/Rose Pine.css | 1 |
4 files changed, 67 insertions, 0 deletions
diff --git a/config/hypr/scripts/waybar_cava.sh b/config/hypr/scripts/waybar_cava.sh new file mode 100755 index 00000000..2ecc4d0b --- /dev/null +++ b/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" diff --git a/config/waybar/configs/[TOP] Default b/config/waybar/configs/[TOP] Default index b40bc576..af1dfa83 100644 --- a/config/waybar/configs/[TOP] Default +++ b/config/waybar/configs/[TOP] Default @@ -25,6 +25,8 @@ "memory", "custom/separator#dot-line", "custom/weather", + "custom/separator#dot-line", + "custom/mviz", ], "modules-center": [ diff --git a/config/waybar/modules b/config/waybar/modules index 2841dc36..919076b2 100644 --- a/config/waybar/modules +++ b/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":{ diff --git a/config/waybar/style/Rose Pine.css b/config/waybar/style/Rose Pine.css index 4a15422b..f055b3b7 100644 --- a/config/waybar/style/Rose Pine.css +++ b/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, |
