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
bofh-excuses


10 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”. :)

Leave a Reply

This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)

You must read and type the 3 chars within 0..9 and A..F, and submit the form.

  

Oh no, I cannot read this. Please, generate a