From 379716c5c891fdbc8c1cc1b48140eaa056a4626d Mon Sep 17 00:00:00 2001 From: William Bell <62452284+Ugric@users.noreply.github.com> Date: Sat, 3 Jan 2026 14:56:51 +0000 Subject: [PATCH] stop all when the soundboard is stopped --- stop_all.sh | 22 +++++++++++----------- stop_soundboard.sh | 14 ++------------ 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/stop_all.sh b/stop_all.sh index 180db36..7d66737 100755 --- a/stop_all.sh +++ b/stop_all.sh @@ -2,16 +2,16 @@ STATE="$HOME/.soundboard" -[[ -f "$STATE/playing.pids" ]] || exit 0 +if [[ -f "$STATE/playing.pids" ]]; then + while read -r PID; do + # Check if process exists before sending SIGINT + if [[ -n "$PID" ]] && kill -0 "$PID" 2>/dev/null; then + kill -INT "$PID" 2>/dev/null || true + fi + done < "$STATE/playing.pids" -while read -r PID; do - # Check if process exists before sending SIGINT - if [[ -n "$PID" ]] && kill -0 "$PID" 2>/dev/null; then - kill -INT "$PID" 2>/dev/null || true - fi -done < "$STATE/playing.pids" + # Clear the PID file after attempting to stop everything + rm -f "$STATE/playing.pids" -# Clear the PID file after attempting to stop everything -rm -f "$STATE/playing.pids" - -echo "All soundboard playback stopped." + echo "All soundboard playback stopped." +fi diff --git a/stop_soundboard.sh b/stop_soundboard.sh index 0f771c6..e0786a0 100755 --- a/stop_soundboard.sh +++ b/stop_soundboard.sh @@ -2,19 +2,9 @@ STATE="$HOME/.soundboard" -[[ -f "$STATE/playing.pids" ]] || exit 0 +SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" -while read -r PID; do - # Check if process exists before sending SIGINT - if [[ -n "$PID" ]] && kill -0 "$PID" 2>/dev/null; then - kill -INT "$PID" 2>/dev/null || true - fi -done < "$STATE/playing.pids" - -# Clear the PID file after attempting to stop everything -rm -f "$STATE/playing.pids" - -echo "All soundboard playback stopped." +$SCRIPT_DIR/stop_all.sh # 2. Restore default mic BEFORE unloading modules DEFAULT_MIC=$(pactl info | grep "Default Source" | awk '{print $3}')