You are not logged in.

#1 2025-01-31 17:02:02

Oli.8080
Member
Registered: 2025-01-31
Posts: 1

Wireplumber: Auto-mute MPD stream when Bluetooth stream detected

Hello community,

I've got a headless media player that plays webradio via MPD 24/7. It has the functionality to allow pre-registered phones to connect via Bluetooth and play their media. Currently, I have to manually mute the webradio (or use a polling script to mute, which I want to avoid) when a Bluetooth stream starts playing, or both MPD and Bluetooth stream will play over each other.

Unfortunatly, I've found the Wireplumber documentation to be deficient to say the least. I've tried a lua script, but couldn't find a way to make it run. Do you have any pointers for me to start looking?

Wireplumber is run by a user, so scripts should be in ~/.config/wireplumber/scripts, correct?

Thanks!
Oli

EDIT: This is the working polling script:

get_mpd_id() {
        wpctl status | awk '/Streams:/ {found=1} found && /Music Player Daemon/ {print $1; exit}' | tr -d '.'
}

BLUETOOTH_STREAM="bluez_input"

monitor_audio() {
        while true; do
                MPD_ID=$(get_mpd_id)
                BT_ACTIVE=$(wpctl status | grep -E "$BLUETOOTH_STREAM")

                if [ -n "$MPD_ID" ] && [ -n "$BT_ACTIVE" ]; then
                        echo "Bluetooth playing, muting MPD (Stream ID: $MPD_ID)..."
                        wpctl set-mute "$MPD_ID" 1
                elif [ -n "$MPD_ID" ]; then
                        echo "Bluetooth stopped playing, unmuting MPD!"
                        wpctl set-mute "$MPD_ID" 0
                fi

                sleep 5
        done
}

monitor_audio

Last edited by Oli.8080 (2025-02-01 16:04:04)

Offline

Board footer

Powered by FluxBB