add all the script needed (hopefully this means i dont need to even make anymore commits lol)

This commit is contained in:
William Bell
2026-01-02 15:25:09 +00:00
commit 0120c6b6b0
4 changed files with 93 additions and 0 deletions

30
play.sh Executable file
View File

@@ -0,0 +1,30 @@
#!/usr/bin/env bash
set -e
FILE="$1"
[[ -f "$FILE" ]] || { echo "Usage: $0 <file>"; exit 1; }
STATE="$HOME/.soundboard"
mkdir -p "$STATE"
DEFAULT_SINK=$(pactl get-default-sink)
# Start paplay processes in foreground
# Store PIDs so we can clean up
paplay --device=soundboard_sink "$FILE" &
PID_MIC=$!
paplay --device="$DEFAULT_SINK" "$FILE" &
PID_OUT=$!
# Trap signals to stop both outputs if script is killed
trap "kill $PID_MIC $PID_OUT 2>/dev/null" EXIT INT TERM
# Register this process in PID file for stop_all.sh
echo $$ >> "$STATE/playing.pids"
# Wait for both streams to finish
wait $PID_MIC $PID_OUT
# Remove from PID file when done
sed -i "\|^$$\$|d" "$STATE/playing.pids"