#!/usr/bin/env bash # Regenerates hyprlua's audio-panel from hyprdrive's supersonic-booster — the # same PipeWire mixer panel (Applications / Output Devices / Input Devices / # General Settings tabs), plain-themed instead of hologram-styled. # # Run BY HAND whenever hyprdrive's supersonic-booster changes and you want # those changes reflected here. Never wired into sysupdate.sh. Modeled # directly on regen-beacon.sh — see that script for the full rationale; the # short version: # # 1. rm -rf + cp -r the hyprdrive source tree in fresh (not an incremental # patch), dropping style/ and any __pycache__. # 2. Copies in the hand-maintained plain stylesheet from # desktopenvs/hyprlua/audio-panel-theme/ (never written to by this # script — edit that by hand for a different plain look). # 3. Flips the copied config.py's hologram default to False (the real # hyprdrive supersonic-booster defaults to True and is never touched by # this script). # 4. Runs one ordered rename table over every file's content AND over # filenames: supersonic-booster -> audio-panel, plus the CamelCase # class-name and UI-label variants actually present in the source # (checked empirically, not guessed — see the grep in the commit that # introduced this script). Also rewrites the literal "hyprdrive" -> # "hyprlua" (docstrings, and critically anything that still points at # desktopenvs/hyprdrive/scripts/ after the rename). # # The rename table intentionally does NOT touch the `.sb-*` CSS class names # supersonic-booster/audio-panel use — that prefix doesn't contain # "supersonic-booster"/"supersonicbooster" as a substring, so the audio-panel # plain stylesheet targets them unchanged. set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" HL="$(cd "$SCRIPT_DIR/.." && pwd)" HD="$(cd "$HL/../hyprdrive" && pwd)" # -- the rename table --------------------------------------------------------- # Order matters: longest/most-specific compounds first, so e.g. # "SupersonicBoosterApp" resolves via its own rule before the bare # "supersonic-booster" rule would otherwise mangle it mid-word. rename_stream() { sed \ -e 's/SupersonicBoosterApp/AudioPanelApp/g' \ -e 's/SupersonicWindow/AudioPanelWindow/g' \ -e 's/Supersonic Booster/Audio Panel/g' \ -e 's/supersonic-window/audio-panel-window/g' \ -e 's/supersonicbooster/audiopanel/g' \ -e 's/supersonic-booster/audio-panel/g' \ -e 's/hyprdrive/hyprlua/g' } rename_file_in_place() { local f="$1" tmp tmp="$(mktemp)" rename_stream < "$f" > "$tmp" mv "$tmp" "$f" } rename_tree_contents() { local dir="$1" f while IFS= read -r -d '' f; do rename_file_in_place "$f" done < <(find "$dir" -type f -print0) } flip_default() { # Flip `"": True` -> `"": False` in a copied config.py's # _DEFAULTS dict. No-op (silently) if the key isn't present. local config_py="$1" key="$2" sed -i "s/\"${key}\": *True/\"${key}\": False/" "$config_py" } # -- per-component regeneration ------------------------------------------------ regen_component() { local src="$1" dst="$2" theme_dir="$3" shift 3 local flip_keys=("$@") rm -rf "$dst" cp -r "$src" "$dst" rm -rf "$dst/style" "$dst/__pycache__" "$dst/lib/__pycache__" "$dst/backend/__pycache__" "$dst/ui/__pycache__" mkdir -p "$dst/style" cp "$theme_dir/_colors.css" "$theme_dir/style.css" "$dst/style/" local key for key in "${flip_keys[@]}"; do flip_default "$dst/config.py" "$key" done rename_tree_contents "$dst" # rename any files/dirs whose *name* itself needs the substitution # (deepest paths first, so renaming a parent dir doesn't orphan a path # to a file inside it that find already queued) local p renamed while IFS= read -r -d '' p; do renamed="$(dirname "$p")/$(basename "$p" | rename_stream)" if [[ "$p" != "$renamed" ]]; then mv "$p" "$renamed" fi done < <(find "$dst" -depth -print0) return 0 } regen_component "$HD/supersonic-booster" "$HL/audio-panel" "$HL/audio-panel-theme" hologram # -- launcher / toggle scripts ------------------------------------------------- regen_script() { local src="$1" dst dst="$SCRIPT_DIR/$(basename "$src" | rename_stream)" rename_stream < "$src" > "$dst" chmod +x "$dst" } regen_script "$HD/scripts/supersonic-booster-start.sh" regen_script "$HD/scripts/supersonic-booster.sh" echo "Regenerated:" echo " $HL/audio-panel/" echo " $SCRIPT_DIR/audio-panel-start.sh, audio-panel.sh"