From 002df77b78492e52952d69b4298a2f92975b981d Mon Sep 17 00:00:00 2001 From: Aiser <2912778691@qq.com> Date: Mon, 24 Nov 2025 02:23:21 +0800 Subject: [PATCH] Matugen: Adjust cava's posthook --- Bin/colors-apply.sh | 38 ++++++++++++++++++++++++++- Services/Theming/TemplateRegistry.qml | 2 +- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/Bin/colors-apply.sh b/Bin/colors-apply.sh index 0c4bff32..d6733fc7 100755 --- a/Bin/colors-apply.sh +++ b/Bin/colors-apply.sh @@ -4,7 +4,7 @@ if [ "$#" -ne 1 ]; then # Print usage information to standard error. echo "Error: No application specified." >&2 - echo "Usage: $0 {kitty|ghostty|foot|alacritty|wezterm|fuzzel|walker|pywalfox}" >&2 + echo "Usage: $0 {kitty|ghostty|foot|alacritty|wezterm|fuzzel|walker|pywalfox|cava}" >&2 exit 1 fi @@ -200,6 +200,42 @@ pywalfox) pywalfox update ;; +cava) + echo "🎨 Applying 'noctalia' theme to cava..." + CONFIG_FILE="$HOME/.config/cava/config" + + # 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." + else + # Check if theme line exists under [color] section + 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" + else + # Add theme line after [color] + sed -i '/^\[color\]/a theme = "noctalia"' "$CONFIG_FILE" + fi + fi + else + echo "[color] section not found, adding it with theme..." + # Add [color] section with theme at the end of file + echo "" >>"$CONFIG_FILE" + echo "[color]" >>"$CONFIG_FILE" + echo 'theme = "noctalia"' >>"$CONFIG_FILE" + fi + else + echo "Error: cava config file not found at $CONFIG_FILE" >&2 + exit 1 + fi + ;; + *) # Handle unknown application names. echo "Error: Unknown application '$APP_NAME'." >&2 diff --git a/Services/Theming/TemplateRegistry.qml b/Services/Theming/TemplateRegistry.qml index 1f18349d..a15b3033 100644 --- a/Services/Theming/TemplateRegistry.qml +++ b/Services/Theming/TemplateRegistry.qml @@ -219,7 +219,7 @@ Singleton { "path": "~/.config/cava/themes/noctalia" } ], - "postProcess": () => `pkill -USR1 cava` + "postProcess": () => `${colorsApplyScript} cava` } ]