The DBus method that listens for the received messages was chocking conky and not allowing the conky script to load correctly. So I had to create two files. getim.py would run at startup, listen for a new message and then write that message to a data file. lastim.py would be executed within conky and check the data file for the new message. I know its not real efficient and redundant but it just works. If you have any brilliant ideas please let me know.
Here is the getim.py file:
#!/usr/bin/python
# ----- GETIM.PY // LISTEN FOR AN RECEIVED MESSAGE ------------#
################################################################
# MOST OF THIS SCRIPT WAS TAKEN FROM THE PIDGIN DEVELOPER WIKI#
# PLEASE VISIT http://developer.pidgin.im/ FOR MORE INFORMATION#
################################################################
def conky_im(account, sender, message, conversation, flags):
reg = '<(.|\n)+?>' # REGEX FOR HTML TAGS
message = re.sub(reg,'',message) # REMOVE HTML TAGS
sender = sender.split("@")[0] # GET GCHAT NAME
message = message[0:24] # LIMIT TO 25 CHARS
file = ' ' # LOCATION OF DATA FILE
fim = open(file,"w")
IM = sender + " said: " + message
fim.write(IM)
fim.close()
import dbus, gobject, re
from dbus.mainloop.glib import DBusGMainLoop
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
bus.add_signal_receiver(conky_im,
dbus_interface="im.pidgin.purple.PurpleInterface",
signal_name="ReceivedImMsg")
loop = gobject.MainLoop()
loop.run()
Copy and paste the following and save as lastim.py:
#!/usr/bin/python
# SHOW LAST IM
f=" " # REPLACE WITH YOUR DATA FILE. ie.CONKYIM.DAT
fim = open(f,'r')
im = fim.read()
print im
fim.close
Finally, add this to your .conkyrc script
${execi 1 python ~/scripts/lastim.py}
Any questions/comments let me know. Here is a screen shot of what my conky looks like: