You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.1 KiB
Bash
46 lines
1.1 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
CARD="alsa_card.pci-0000_03_00.1"
|
|
CARD_SUFFIX="${CARD#alsa_card.}"
|
|
STEREO_PROFILE="output:hdmi-stereo-extra3"
|
|
SURROUND_PROFILE="output:hdmi-surround71-extra3"
|
|
|
|
echo "Switching ONKYO to 7.1..."
|
|
pactl set-card-profile "$CARD" "$SURROUND_PROFILE"
|
|
|
|
sleep 2
|
|
|
|
echo "Switching ONKYO to stereo..."
|
|
pactl set-card-profile "$CARD" "$STEREO_PROFILE"
|
|
|
|
echo "Clearing default sink configuration..."
|
|
wpctl clear-default
|
|
|
|
sleep 3
|
|
|
|
echo "Launching Kodi..."
|
|
flatpak run tv.kodi.Kodi &
|
|
KODI_PID=$!
|
|
|
|
trap 'kill "$KODI_PID" 2>/dev/null || true; wait "$KODI_PID" 2>/dev/null || true' INT TERM
|
|
|
|
wait "$KODI_PID" || true
|
|
|
|
echo "Kodi exited. Restoring 7.1 profile and default sink..."
|
|
pactl set-card-profile "$CARD" "$SURROUND_PROFILE"
|
|
|
|
# Give PipeWire a moment to expose the sink for the new profile
|
|
sleep 1
|
|
|
|
SINK="alsa_output.${CARD_SUFFIX}.hdmi-surround71-extra3"
|
|
if pactl list short sinks | awk '{print $2}' | grep -qx "$SINK"; then
|
|
pactl set-default-sink "$SINK"
|
|
echo "Default sink set to: $SINK"
|
|
else
|
|
echo "Warning: sink '$SINK' not found; listing available sinks:" >&2
|
|
pactl list short sinks >&2
|
|
fi
|
|
|
|
echo "Done."
|