| #!/usr/bin/python |
| |
| import sys |
| import dbus |
| |
| bus = dbus.SystemBus() |
| |
| manager = dbus.Interface(bus.get_object("org.bluez", "/"), "org.bluez.Manager") |
| adapter = dbus.Interface(bus.get_object("org.bluez", manager.DefaultAdapter()), |
| "org.bluez.Adapter") |
| |
| if len(sys.argv) < 3: |
| print """Usage: %s <command> |
| |
| connect <bdaddr> |
| disconnect <bdaddr> |
| """ % sys.argv[0] |
| sys.exit(1) |
| |
| device = adapter.FindDevice(sys.argv[2]) |
| audio = dbus.Interface(bus.get_object("org.bluez", device), |
| "org.bluez.Audio") |
| |
| if sys.argv[1] == "connect": |
| audio.Connect() |
| elif sys.argv[1] == "disconnect": |
| audio.Disconnect() |
| else: |
| print "Unknown command" |
| sys.exit(1) |