View Single Post
Posts: 21 | Thanked: 4 times | Joined on Apr 2008
#9
I tried to hack this together myself.
But its not working.
I used the deb installer and replaced /usr/lib/hsetvtrl/hsetctrl.py with the below script which used dbus to start and stop canola/mplayer.

If i run just 'dbus-send --dest=com.nokia.osso_media_server /com/nokia/osso_media_server com.nokia.osso_media_server.music.pause' in the terminal while canola is running I get a working play/pause system. However this does not work when trying to use it in the script below.


Here's the script I am using:
Code:
#!/usr/bin/env python2.5
from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True)

import dbus
import gobject
import os

def main():

	dbus_loop = gobject.MainLoop()
	bus = dbus.SystemBus()


		def on_button_pressed (sender=None):
		os.system('run-standalone.sh dbus-send --dest=com.nokia.osso_media_server /com/nokia/osso_media_server com.nokia.osso_media_server.music.pause 2> /dev/null 1> /dev/null')
    

headset = bus.get_object('com.nokia.osso_hp_ls_controller', '/com/nokia/osso_hp_ls_controller')
headset_iface = dbus.Interface(headset, dbus_interface='com.nokia.osso_hp_ls_controller.headset')
headset_iface.connect_to_signal('button_pressed', on_button_pressed, sender_keyword='sender')

	dbus_loop.run()

if __name__ == "__main__":
	main()
Do you see any flaws? Why does my bluetooth button not calling the dbus command properly? I'm not to certian what all is done by the deb installer, and im a python newb. so, any comments are welsome.