Showing posts with label Fortune. Show all posts
Showing posts with label Fortune. Show all posts

Thursday, March 26, 2009

Fortune Status for Pidgin IM

If you want to change status message of Pidgin Message by
fortune message. Just create a file pidgin_status_message.py
And copy the following lines.

#----------------------------

#!/usr/bin/env python

import dbus,subprocess,time

def set_status(message):
  bus = dbus.SessionBus()
  obj = bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject")
  purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface")
  current = purple.PurpleSavedstatusGetType(purple.PurpleSavedstatusGetCurrent())
  status = purple.PurpleSavedstatusNew("", current)
  purple.PurpleSavedstatusSetMessage(status, message)
  purple.PurpleSavedstatusActivate(status)

while
True:
  fortune = subprocess.Popen('fortune', stdout = subprocess.PIPE).stdout.read()
  set_status(fortune)
  time.sleep(120)
#-------------------------------

Start Pidgin and give following command:
$ python pidgin_status_message.py &