How to set Pidgin status from command line?

1.4k views Asked by At

How can I set/change my status (like Available/Busy/Away) in Pidgin instant messenger from the command line? I needed this to make sure that my status changes to 'Away' whenever I lock my screen. I installed the 'awayonlock' plugin, but it doesn't seem to work with MATE desktop environment.

1

There are 1 answers

0
Jerry George On BEST ANSWER

I was able to create a simple python script to do this:

set_im_status.py

#!/usr/local/bin/python

import sys
import dbus, gobject
from dbus.mainloop.glib import DBusGMainLoop

dbus_loop = DBusGMainLoop()

bus = dbus.SessionBus(mainloop=dbus_loop)
dbus_obj = bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject")
purple = dbus.Interface(dbus_obj, "im.pidgin.purple.PurpleInterface")

status = sys.argv[1]

# Available
if status == "a":
    status_id = dbus.String(u'available')

# Busy
elif status == "b":
    status_id = dbus.String(u'unavailable')

# Away
elif status == "w":    
    status_id = dbus.String(u'away')

# Invisible
elif status == "i":
    status_id = dbus.String(u'invisible')

# Offline
elif status == "f":
    status_id = dbus.String(u'offline')

else:
    status_id = dbus.String(u'available')

status_type = purple.PurplePrimitiveGetTypeFromId(status_id)
saved = purple.PurpleSavedstatusNew("", status_type)
purple.PurpleSavedstatusActivate(saved)

Now to set the status to 'Busy', run: % python set_im_status.py b