[Ekiga-list] python dbus script - pcspeaker



Hi All!

I hacked up a little script which employs the pcspeaker as a ring device for ekiga. If someone has already posted something similar before I apologize.

For the script to work;
Ekiga needs to be compiled with dbus support

Depending on your distro you will need packages that provide:
  - beep (a program which beeps the pcspeaker)
  - python-dbus bindings (on gentoo they are included with dbus...I think)
  - pygtk

If you are using Linux, you will need a kernel compiled with
 - CONFIG_INPUT_PCSPKR

Note that beep might need to be set suid root to work when it's not used from a terminal. Look at the beep man-page for more information.

Put the script in one of your session startup scripts. On my machine I have selected the script to be started along with gnome in the control-center dialog. It does not matter whether the script is launched before or after ekiga. A dbus session must exist though.

The script can be extended in many ways, for example i use the python dcop extension to pause amarok when ekiga is ringing and a call is connected.

http://gitweb.freedesktop.org/?p=dbus-dbus-python;a=summary

Hope someone else will find this useful.

Regards,

Fredrik Axelsson
#!/usr/bin/python

import os
import gobject
import dbus

if getattr(dbus, 'version', (0,0,0)) >= (0,41,0):
	import dbus.glib

bRunSound=False

def ekiga_name_changed_callback(first, second, third):
  global bRunSound 
  print "Ekiga nameowner changed %s %s %s" % (first, second, third)
  bRunSound=False
  

def ekiga_state_changed_callback(first, second):
  print 'Ekiga State %s %u' % (first, second)
  global bRunSound
  if second != 4:
    bRunSound = False
  if second == 4:
     if bRunSound == False:
        bRunSound = True
        gobject.timeout_add(1000,timeout_function)	

def timeout_function():
   global bRunSound	
   os.system("beep -f 300.7 -r 2 -d 100 -l 400")
   return bRunSound

bus = dbus.SessionBus()
bus.add_signal_receiver(ekiga_state_changed_callback, dbus_interface = "net.ekiga.calls", signal_name = "StateChanged")
bus.add_signal_receiver(ekiga_name_changed_callback, dbus_interface = "org.freedesktop.DBus", signal_name = "NameOwnerChanged", arg0="net.ekiga.instance")
mainloop = gobject.MainLoop()
mainloop.run()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]