#!/bin/bash SINKS=$(pacmd list-sinks) DEVICE="bluez_card.04_52_C7_C0_ED_BE" IFS=$'\r' case $(echo "$SINKS" | grep 'bluetooth.protocol' | awk '{print $3}') in "\"a2dp_sink\"") pacmd set-card-profile $DEVICE headset_head_unit 1>/dev/null 2>&1 ;; "\"headset_head_unit\"") pacmd set-card-profile $DEVICE a2dp_sink 1>/dev/null 2>&1 ;; esac