From 9920450b17a76f4b5d2396878489b2cbc0176fcb Mon Sep 17 00:00:00 2001 From: Gopher Date: Thu, 20 Mar 2025 16:18:42 +0530 Subject: [PATCH] Changes in: waybar, --- waybar/config.jsonc | 28 ++++------------------------ waybar/scripts/cava.sh | 38 +++++++++++++++++++++++++++++--------- waybar/style.css | 5 +++-- 3 files changed, 36 insertions(+), 35 deletions(-) diff --git a/waybar/config.jsonc b/waybar/config.jsonc index 961bc47..8d547e2 100644 --- a/waybar/config.jsonc +++ b/waybar/config.jsonc @@ -18,6 +18,10 @@ // "bluetooth", "battery" ], + "custom/cava": { + "format": "{}", + "exec": "~/.config/waybar/scripts/cava.sh" + }, "temperature#gpu": { "thermal-zone": 5, "critical-threshold": 80, @@ -25,30 +29,6 @@ "format": "{temperatureC}°C ", "tooltip": false }, - "custom/cava": { - // "cava_config": "$XDG_CONFIG_HOME/.config/cava/config", - "framerate": 30, - "autosens": 1, - // "sensitivity": 100, - "bars": 14, - "lower_cutoff_freq": 50, - "higher_cutoff_freq": 10000, - "method": "pulse", - "exec": "~/.config/waybar/scripts/cava.sh", - "interval": 0.05, - "source": "auto", - "stereo": true, - "reverse": false, - "bar_delimiter": 0, - "monstercat": false, - "waves": false, - "noise_reduction": 0.77, - "input_delay": 2, - "format-icons": ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"], - "actions": { - "on-click-right": "mode" - } - }, "backlight": { "device": "intel_backlight", "scroll-step": 5, diff --git a/waybar/scripts/cava.sh b/waybar/scripts/cava.sh index 0c0d994..d33ff08 100755 --- a/waybar/scripts/cava.sh +++ b/waybar/scripts/cava.sh @@ -1,10 +1,30 @@ -#!/bin/bash -is_cava_ServerExist=`ps -ef|grep -m 1 cava|grep -v "grep"|wc -l` -if [ "$is_cava_ServerExist" = "0" ]; then - echo "cava_server not found" > /dev/null 2>&1 -# exit; -elif [ "$is_cava_ServerExist" = "1" ]; then - killall cava -fi +#! /bin/bash -cava -p ~/.config/cava/config | sed -u 's/;//g;s/0/▁/g;s/1/▂/g;s/2/▃/g;s/3/▄/g;s/4/▅/g;s/5/▆/g;s/6/▇/g;s/7/█/g;' +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 = 6 + +[output] +method = raw +raw_target = /dev/stdout +data_format = ascii +ascii_max_range = 5 +" > $config_file + +# read stdout from cava +cava -p $config_file | while read -r line; do + echo $line | sed $dict +done \ No newline at end of file diff --git a/waybar/style.css b/waybar/style.css index 5c1e827..8e4bc4d 100644 --- a/waybar/style.css +++ b/waybar/style.css @@ -17,9 +17,10 @@ color: #8fbc8f; border-left: 0px; border-right: 0px; - padding-bottom: 6px; + padding: 6px; font-family: 'bargraph'; - font-size: 22px; + background: @raisin-black; + margin: 0px 2px; } #cpu {