Created
June 16, 2020 17:10
-
-
Save ayosec/b927c7a57d226453a7a16a20e9ffc1ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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