#!/bin/sh # # Start/stop routing PCM to headset DESC="routing PCM to headset" BTADDR="00:16:8F:EB:6E:53" case "$1" in start) echo "Start $DESC:" echo "ActivateService string:audio" dbus-send --system --type=method_call --print-reply --dest=org.bluez \ /org/bluez org.bluez.Manager.ActivateService string:audio > .answer DESTINATION=`grep string .answer | sed -e "s/string//g" -e "s/\ //g" -e "s/\"//g"` echo "DESTINATION=$DESTINATION" echo $DESTINATION > .destination echo "Manager.CreateHeadset" dbus-send --system --type=method_call --print-reply --dest="$DESTINATION" \ /org/bluez/audio org.bluez.audio.Manager.CreateHeadset string:$BTADDR > .answer DEVICEPATH=`grep string .answer | sed -e "s/string//g" -e "s/\ //g" -e "s/\"//g"` echo "DEVICEPATH=$DEVICEPATH" echo $DEVICEPATH > .devicepath echo "Headset.Connect" dbus-send --system --type=method_call --print-reply --dest="$DESTINATION" \ "$DEVICEPATH" org.bluez.audio.Headset.Connect echo "Headset.Play" dbus-send --system --type=method_call --print-reply --dest="$DESTINATION" \ "$DEVICEPATH" org.bluez.audio.Headset.Play echo "Done." ;; stop) echo "Stop $DESC:" DESTINATION=`cat .destination` echo "DESTINATION=$DESTINATION" DEVICEPATH=`cat .devicepath` echo "DEVICEPATH=$DEVICEPATH" echo "Headset.Stop" dbus-send --system --type=method_call --print-reply --dest="$DESTINATION" \ "$DEVICEPATH" org.bluez.audio.Headset.Stop echo "Headset.Disconnect" dbus-send --system --type=method_call --print-reply --dest="$DESTINATION" \ "$DEVICEPATH" org.bluez.audio.Headset.Disconnect echo "Manager.RemoveHeadset" dbus-send --system --type=method_call --print-reply --dest="$DESTINATION" \ /org/bluez/audio org.bluez.audio.Manager.RemoveHeadset string:$DEVICEPATH echo "Done." ;; esac exit 0