From 9d3aacc5f1081ccc607353f1c65dc18aa31fb723 Mon Sep 17 00:00:00 2001 From: Aiser <2912778691@qq.com> Date: Mon, 24 Nov 2025 02:56:23 +0800 Subject: [PATCH] Matugen: Fix cava theme can't hot reload --- Bin/colors-apply.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Bin/colors-apply.sh b/Bin/colors-apply.sh index d6733fc7a..16574ba70 100755 --- a/Bin/colors-apply.sh +++ b/Bin/colors-apply.sh @@ -203,13 +203,13 @@ pywalfox) cava) echo "🎨 Applying 'noctalia' theme to cava..." CONFIG_FILE="$HOME/.config/cava/config" + THEME_MODIFIED=false # Check if the config file exists. if [ -f "$CONFIG_FILE" ]; then # Check if [color] section exists if grep -q '^\[color\]' "$CONFIG_FILE"; then echo "[color] section found, checking theme setting..." - # Check if theme is already set to noctalia under [color] if sed -n '/^\[color\]/,/^\[/p' "$CONFIG_FILE" | grep -q '^theme = "noctalia"'; then echo "Theme already set to noctalia under [color], skipping modification." @@ -218,9 +218,11 @@ cava) if sed -n '/^\[color\]/,/^\[/p' "$CONFIG_FILE" | grep -q '^theme = '; then # Replace existing theme line under [color] sed -i '/^\[color\]/,/^\[/{s/^theme = .*/theme = "noctalia"/}' "$CONFIG_FILE" + THEME_MODIFIED=true else # Add theme line after [color] sed -i '/^\[color\]/a theme = "noctalia"' "$CONFIG_FILE" + THEME_MODIFIED=true fi fi else @@ -229,6 +231,20 @@ cava) echo "" >>"$CONFIG_FILE" echo "[color]" >>"$CONFIG_FILE" echo 'theme = "noctalia"' >>"$CONFIG_FILE" + THEME_MODIFIED=true + fi + + # Reload cava if it's running + if pgrep -f cava >/dev/null; then + echo "Reloading cava configuration..." + pkill -USR1 cava + echo "✅ Cava reloaded successfully" + else + if [ "$THEME_MODIFIED" = true ]; then + echo "✅ Configuration updated. Start cava to see the changes." + else + echo "✅ Configuration already correct." + fi fi else echo "Error: cava config file not found at $CONFIG_FILE" >&2