Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
MAC=01_23_45_67_89_AB
FILTER=$(paste -sd, <<FILTER
type='signal'
sender='org.bluez'
interface='org.freedesktop.DBus.Properties'
path='/org/bluez/hci0/dev_$MAC'
member='PropertiesChanged'
arg0='org.bluez.Device1'
FILTER
)
dbus-monitor --system "$FILTER" \
| sed -u '/^signal/ { :s N; /]/be; bs; :e s/\n//g }' \
| grep --line-buffered 'Connected.*true' \
| while read
do
dbus-send \
--system \
--print-reply \
--dest=org.bluez \
--type=method_call \
/org/bluez/hci0/dev_$MAC \
org.bluez.Device1.Connect
pactl set-card-profile "bluez_card.$MAC" "a2dp_sink"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.