pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

Python pastebin - collaborative debugging tool View Help


Posted by Robert Jordens on Mon 6 Aug 19:47
report spam | download | new post

  1. #!/usr/bin/python
  2. import os
  3. import dbus, gobject, dbus.glib
  4. import dbus.decorators
  5. import gtk
  6. import mx610
  7.  
  8. sysbus = dbus.SystemBus()
  9. sesbus = dbus.SessionBus()
  10.  
  11. notify_obj = sesbus.get_object('org.freedesktop.Notifications',
  12.     '/org/freedesktop/Notifications')
  13. notifications = dbus.Interface(notify_obj,
  14.     'org.freedesktop.Notifications')
  15.  
  16.  
  17.  
  18. icon = gtk.StatusIcon()
  19. icon.set_visible(False)
  20. icon.set_from_icon_name('evolution')
  21. icon.set_tooltip('New mail arrived!')
  22.  
  23. watch_boxes = [
  24.         "INBOX",
  25.         "INBOX/big",
  26.         "ethz/qo",
  27.         "lists/debian/devel/announce"
  28.         ]
  29.  
  30.  
  31. def safe_mx610_state(*a, **k):
  32.     try:
  33.         mo = mx610.mx610("/dev/hiddev0")
  34.         mo.state(*a, **k)
  35.     except:
  36.         pass
  37.  
  38. def newmail_received(box_path, box_name):
  39.     #os.system('play /usr/share/sounds/gaim/receive.wav >/dev/null 2>&1 &')
  40.     if box_name in watch_boxes:
  41.         gobject.idle_add(icon.set_visible, True)
  42.         notifications.Notify('dbus-hooks', 0, '', 'New Mail!',
  43.             "New mail in " + box_name, [], {}, -1)
  44.         safe_mx610_state(s0="on")
  45.  
  46. def newmail_read(*args, **keywords):
  47.     gobject.idle_add(icon.set_visible, False)
  48.     safe_mx610_state(s0="off")
  49.  
  50. sesbus.add_signal_receiver(newmail_received, signal_name='Newmail',
  51.     dbus_interface='org.gnome.evolution.mail.dbus.Signal',
  52.     path='/org/gnome/evolution/mail/newmail')
  53.  
  54. sesbus.add_signal_receiver(newmail_read, signal_name='MessageReading',
  55.     dbus_interface='org.gnome.evolution.mail.dbus.Signal',
  56.     path='/org/gnome/evolution/mail/newmail')
  57.  
  58.  
  59. def gaim_gotmsg(a, fr, body, b, c):
  60.     # print fr, body
  61.     safe_mx610_state(s1="pulse")
  62.  
  63. def gaim_viewedmsg(a, fr, body, b, c):
  64.     # print fr, body
  65.     safe_mx610_state(s1="off")
  66.  
  67. sesbus.add_signal_receiver(gaim_gotmsg, signal_name='ReceivingImMsg',
  68.     dbus_interface='net.sf.gaim.GaimInterface',
  69.     path='/net/sf/gaim/GaimObject')
  70.  
  71. sesbus.add_signal_receiver(gaim_viewedmsg, signal_name='DisplayedImMsg',
  72.     dbus_interface='net.sf.gaim.GaimInterface',
  73.     path='/net/sf/gaim/GaimObject')
  74.  
  75.  
  76. mainloop = gobject.MainLoop()
  77. mainloop.run()

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me