View Single Post
JonWW's Avatar
Posts: 623 | Thanked: 289 times | Joined on Jan 2010 @ UK
#2
To switch bluetooth on
Code:
dbus-send --system --type=method_call --dest=org.bluez $(dbus-send --system --print-reply --dest=org.bluez / org.bluez.Manager.ListAdapters | awk -F'"' '/at/ {print $2}') org.bluez.Adapter.SetProperty string:Powered variant:boolean:true
To switch bluetooth off
Code:
dbus-send --system --type=method_call --dest=org.bluez $(dbus-send --system --print-reply --dest=org.bluez / org.bluez.Manager.ListAdapters | awk -F'"' '/at/ {print $2}') org.bluez.Adapter.SetProperty string:Powered variant:boolean:false
Use dbus-monitor to monitor the system and trigger an event when you get/make a call
Code:
dbus-monitor --help
For example this will catch when the keyboard is opened or closed.
Code:
dbus-monitor --monitor --system type='signal',interface='org.freedesktop.Hal.Device',path='/org/freedesktop/Hal/devices/platform_slide',member='Condition'|while read LINE
  do
    echo "$LINE"|grep -o "cover"
  done
The only problem is will the bluetooth connect to your headset in time before the caller hangs up.
 

The Following 4 Users Say Thank You to JonWW For This Useful Post: