add all the script needed (hopefully this means i dont need to even make anymore commits lol)
This commit is contained in:
30
play.sh
Executable file
30
play.sh
Executable 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"
|
||||
Reference in New Issue
Block a user