Posted by: Sameer Agarwal | July 2, 2008

Fun with GTalk/Pidgin: Changing your status messages programatically

We have always seen people trying to come up with catchy one-liners and cool slogans as their gtalk status messages. On being unable to come up with cool, funky and _original_ status messages to impress friends and colleagues, I decided to put on the programmer’s hat and came up with ways to set these status messages through a simple program. Advantages? Well, enormous. Once you can control the status message string through a program, you can basically rotate it (Rotating status messages do look cool ), update it automatically every 1 minute, write a scripts that ‘copies’ your friends status messages periodically… Seriously, the opportunities are limitless and only await your imagination! GTalk status messages can be thought on the lines of a Publish-Subscribe Messaging. To understand this, think of a simple newspaper. It publishes some information everyday and its reader in a way subscribe to this information. In the same way your messenger status message is published by youand it is “subscibed” by your friends. This can be thought of as a kind of Multicasting group. So, as part of this blog, I will basically discuss the Google Talk XMPP protocol and will focus on 2 popular IM that use this: GTalk for Windows and Pidgin for Linux (actually pidgin is multi platform)

Configuring Pidgin (in Linux):

For this you will need libpurple-bin to be installed on your system. You can find this in all common linux repositories. For eg. in Ubuntu, this can be done by a simple command:

$ sudo apt-get install libpurple-bin

Once this is done, we need a simple shell script to change our status message. For eg. the script below, makes the current date/time being set up in the status message in case you are “available” in the format :

Wed Jul  2 13:46:53 EDT 2008

and updates it every 30 seconds.

while test 1 = 1; do
if test "`purple-remote getstatus`" = "available"; then
purple-remote "setstatus?status=available&message=${msg}"
sleep "${sleep_time}s"

This file can be downloaded here.

Let us call it

Now what remains is just to execute this with pidgin running and you are done! The status messages will keep on changing every 30 seconds and I guarantee it will be fun! Please don’t tamper much with the sleep time because while you are chatting, your status message is displayed on your friend’s side whenever it is changed. So you can imagine that it becomes quite irksome for your friend to continuously notice your status message change.

Configuring GTalk (in Windows):

Configrung GTalk messages programatically in Windows is a little tricky (another reason to switch to open source linux ) . For this, you need to have a Java Development environment in your system as we need to write XMPP application code using a well known API called Smack API which is in Java.

So, first of all, let us start with installing Java on the system (if you donot already have it) which you can get here. Once this is done, we need to get the Smack API which is an open source, pure Java library for working with XMPP (clients only). The API can be downloaded from The source code for this can be obtained from download the appropriate libraries and put the JAR files in your classpath. If you can’t figure out how it is done, please Google your way around or refer this.

Now, we get down on writing the code!

The java file will look like:

// Import appropriate headers and packages
    XMPPConnection connection = new XMPPConnection("");
      connection.login("username", "password");
      Presence presence = new Presence(Presence.Type.available);
      presence.setStatus("Hello Friends!");
      Thread.sleep(30000);  // Sleeps for 30 seconds
    catch (XMPPException e)

The thing to notice here is that the argument of setStatus is a String. So, to rotate your status message, just use the following function:

    private static String rotate(String input)
        return input.substring(1) + input.charAt(0);

which takes in a simple string as input and rotates it one character at a time:




So, get down to it and Enjoy!



  1. yup !!
    I have done this !!

  2. wow, that was cool. It works for me, but only once. The next time i ran the script, the status wont change. Text box below the buddy list keep changing as the code work, but the real status below my name doesnt change at all. And the worst, i cant change my status again :((

  3. @ Siddharth
    Yes, you were the one who gave me the initial idea to explore lib-purple and the Smack API 🙂

  4. @habib
    That should not happen… by any chance are you running gmail, gtalk along with pidgin? These have high priority over pidgin for setting the status message. So, that might be the case.

  5. From whatever little I could understand from this, I think it’s a cool idea!! You’re the high-funda programmer!! Yay! 😀
    I will approach u for any software queries I have! 😀
    Added you to my blogroll… I like your blog.. Sorry, I”m a bit late to arrive here, but I was held up with some shitty work… 🙂

  6. It worked fine.But the status is updated as long as the program runs. After the program ends. The status is set back to the previous one. Do you have any work around for that? Or am I doing something wrong?

  7. This is so cool!
    I used the above method to set the countdown to Chandrayaan-1 as my status message. I’m pretty excited about both 🙂

  8. once i tried a similar thing in python! every minute the status message gets updated with fortunes 🙂

  9. Great Article

  10. You really don’t need to do all this, if you know a lil PHP then JAXL client library makes everything easy for you.

    Download it from here

  11. Hey Sameer,

    Is there any docs for libpurple? The only thing I could find for libpurple-dev was

    There is no docs for libpurple-bin, even the devs said that libpurple isnt documented.

    Any guidance?

    • Manish, I too had a big problem in finding docs on libpurple. But then what I needed was just a combination of few hacks here and there 🙂

  12. Excelent !!
    now purple-remote + fortune, for lot’s of fun

  13. I get above message while running the program.

    SASL authentication failed using mechanism PLAIN:


  14. Remember to enter the full email address including the part.
    connection.login(“username”, “password”);

    Also, the status message reverts back to the original one once the program terminates. Any way to get around this?

    • @Sniper: I agree that this is a problem. I think that it has got to do something with the fact that gtalk/pidgin has more priority over Smack/libpurple. But frankly speaking, I couldn’t find a way. Please do let me know if you come across something to solve this. Thanks!

  15. can u give me the exact program.plzz..instead of the rough program…i am new to java…and i need to know what packages should i import….

  16. I created a VERY simple python script for randomizing your status every 30 seconds. It reads in the file “mystatus.txt”.

    #!/usr/bin/env python

    import os
    import random
    import time
    from subprocess import Popen,PIPE

    # Don’t forget to populate mystatus.txt! One entry per line
    infile = file(‘mystatus.txt’, ‘r’)
    line = infile.readlines()
    totlines = len(line)
    go = 1

    def setstatmsg():
    while go == 1:
    rand = random.randrange(0, totlines)
    tst = line[rand].strip()
    print ‘Setting status to ‘ + tst
    setit = ‘purple-remote ‘ + ‘”setstatus?status=available&message=’ + tst + ‘”‘
    p = Popen(setit, shell=True, stdout=PIPE)
    response = p.communicate()[0]
    print response

    def getstatus():
    cmd = ‘purple-remote’, ‘getstatus’
    p = Popen(cmd, shell=False, stdout=PIPE)
    stdout_value = p.communicate()[0]
    newval = stdout_value.strip()
    if newval == ‘available’:
    print ‘Current status is: “‘ + newval + ‘”. Time to randomize!’
    print ‘Either Pidgin not running or status not set to “available”‘

    • Thanks emdub for sharing your python script. The key to changing status messages in pidgin is simply the purple-remote command of “setstatus?status=available&message=${msg}”. The rest is all syntactic sugar which is different in different languages 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: