09
Mar
08

Setting Pidgin Status with Python or How to Waste Perfectly Good Saturday

I was very bored today. Tired from working on Ratuus (don’t go there, site is under heavy construction :)) I needed something to help me take my mind off everything. And what better way to do it, than playing with Python, Pidgin and D-BUS. :D

To cut the long story short, I needed something that will update my Pidgin status message with the information about the current song I am listening. Till recently I was using Rhythmbox player and there is a perfect little Pidgin plugin called Current Track that worked with this player. Last week I discovered gmusicbrowser and fell in love immediately. It is fast, rich with functionalities but still simple to use. Exactly what I want from audio player. (Hm, I just noticed it is written in PERL. Now when Python is used for everything this comes as a big surprise.)

gmusicbrowser already has a plugin called NowPlaying. It will trigger some command whenever song is changed. I just needed to write this command that will inform Pidgin about the change. So, this seemed like a perfect exercise for slow Saturday. :)

Quick search on Pidgin and D-BUS showed extensive documentation about Pidgin API accessible through D-BUS. There is even a working example of how to change the status message! :)

But that was too simple, so I got another idea. Some time ago, I wrote a small daemon in C that will bind to a specific port and display random bofh-excuses fortune messages when someone would telnet to it. (Seems like I have a lot of spare time. I should really find some hobby!) Something similar to telnet bofh.jeffballard.us 666 (here for more information). So I was thinking about implementing the same for my Pidgin status. Random BOFH excuses in your status message! How cool geeky is that!

The result of all that is short (~60 lines of code) Python script that will set your Pidgin status message to:

a) you current song

pidgin_status.py -m The Real McKenzies – Outta Scotch

b) random line from a file

pidgin_status.py -f /usr/local/share/bofh-example

c) anything you give as the command line argument

pidgin_status.py Some very interesting and funny status message

Only difference between a) and c) is the type of the icon that will be shown. In example a) there will be a small musical note, while in example b) and c) nice arrow pointing to right side will be show.

In the middle of testing I noticed this strange message:

Being from Serbia myself, I find this extremely funny. Although, I didn’t know Serbian hackers are so notorious! :)

I hope someone will find it useful. In any case, I am accepting donations for some long and adventurous vacation. As you can see, I really need it! :D

pidgin_status.py


23 Responses to “Setting Pidgin Status with Python or How to Waste Perfectly Good Saturday”


  1. 1 z Mar 10th, 2008 at 10:31 pm

    Your life is really boring if you are doing this during the weekends :-)

  2. 2 miljan Mar 10th, 2008 at 10:40 pm

    Not really. I mean, not always! :P

  3. 3 alice Apr 17th, 2008 at 10:55 am

    (Seems like I have a lot of spare time. I should really find some hobby!)

    …you could go take some nice photographs for example :-P

  4. 4 Azhar Apr 22nd, 2008 at 4:55 am

    Gee… i have life as boring as yours, but your script is awesome. I’ve add a switch -g witch add a link to google search next after the status.

    ….and now i can make some silly status next from my pidgin, as silly as my self.

    Thanks.

  5. 5 bleketux Aug 5th, 2008 at 3:00 am

    Is it possible to create timed random line from a file ? Let say, I would like to change the status every 10 minute randomly… is it possible ? can you do it for me on your next weekend :D ? Please :(

  6. 6 miljan Aug 5th, 2008 at 9:35 am

    You don’t really need a special script for that. You can just add a line into the crontab to be executed every 10 minutes. For example:

    */10 * * * * /usr/local/bin/pidgin_status.py -f /usr/local/share/bofh-example

    This solves your problem. :)

  7. 7 miljan Aug 5th, 2008 at 11:31 am

    Update:
    Method above will not work. I forgot that D-BUS session is only available from the session itself (it is created when your graphical environment is started). So cron is not able to update it.
    I will try to modify the script to include your request ASAP. :)

  8. 8 bleketux Aug 6th, 2008 at 2:20 am

    thanks…
    I’ll wait the updated script…

  9. 9 DASPRiD Oct 20th, 2008 at 9:16 pm

    Hehe, I made a similar script some time ago (had the same, a weekend and lots of spare time ;)), take a look:

    http://www.dasprids.de/blog/2008/06/28/pidgin-status-switcher

  10. 10 miljan Oct 21st, 2008 at 9:50 am

    Hello Ben, thanx for dropping by. :)

    Weekends can be quite long sometimes. Perfect for this small ideas we get from time to time. :)

    BTW, I am moving to Germany (Frankfurt/M) in 10 days. Any suggestions what could I expect would be more than grateful. :)

    I already have a picture (I’ve been there two times already) but it is always good to hear it from “locals”. :)

  11. 11 Ben Scholzen Feb 25th, 2009 at 6:36 pm

    Hey, sorry for not answering you, but how should I’ve known that you’ve written here? ;) Probably you want to mail me?

  12. 12 Lynoure Braakman Mar 22nd, 2009 at 7:27 pm

    Thanks for the script.

    I tend to like to keep track of where my quotes are coming from, thus I changed it to exclude lines that are commented out with #.
    You can find my patch at:
    http://lynoure.org/pidgin_status_comments.patch

  13. 13 Akash May 7th, 2009 at 12:21 pm

    awesome dude. thanks :D

  14. 14 miljan May 7th, 2009 at 8:47 pm

    Welcome ;)

  15. 15 anilalur May 10th, 2009 at 11:33 am

    Next time I feel my weekend is boring, I am adding ASCII art to the status n animate it :)

  16. 16 HyperHacker Jul 19th, 2009 at 8:42 am

    Hey, this is actually useful. Set it to choose different messages depending on time of day, and call it from BlueProximity… it automatically switches to “at work” or “asleep” or whichever when I leave.

    …at least it would, if I bothered to learn enough Python to do that. :-p

  17. 17 Lars Friedrichs Jul 23rd, 2009 at 10:07 am

    Hi HyperHacker,

    where is your problem with BlueProximity? It should do what you want with no python and little shell scripting knowledge…
    I know BlueProximity can do that because I wrote it :-)

    Bye
    Lars

  18. 18 Michel Nov 3rd, 2009 at 8:41 pm

    This could be useful to me.

    I want pidgin to show where I am. @Home, @office, @customerX, @customerY, etc.

    I saw some dudes that rewrite the statuses.XML file, but this seems a lot better.

    I tolled my computer how to link the IP address/gateway/domain to a location but wasn’t sure how to bring that to a pidgin status.

    Thanks for wasting a Saturday morning on this.

  19. 19 miljan Nov 3rd, 2009 at 10:08 pm

    Wow, I am more than surprised how many people are finding this useful! :)
    Thanx! :)

  20. 20 kaa Mar 11th, 2010 at 5:22 pm

    Hi,
    I’m from Russia. i have some problems with Cyrillic song titles,
    I’ve patched your plug-in (with patch from Lynoure Braakman). Now send it status in utf-8.

    Patch file:
    http://www.yourfilelink.com/get.php?fid=534863

    from Russia with Love! ;)

  21. 21 miljan Mar 11th, 2010 at 11:13 pm

    Hi Kaa,

    thanx for the patch. I don’t know how I managed to do it, but it seems I completely missed Lynoure’s comment together with the patch. I will include both patches now.

    thanx again ;)

  22. 22 Willie Matthews Sep 17th, 2011 at 12:37 am

    Very useful script! Thanks for taking the time to do it 3 years ago! :~)

  23. 23 JoeD Jan 4th, 2012 at 2:54 pm

    Great work! Exactly what I was looking for. :D

Comments are currently closed.