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
Your life is really boring if you are doing this during the weekends :-)
Not really. I mean, not always! :P
(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
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.
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 :(
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. :)
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. :)
thanks…
I’ll wait the updated script…
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
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”. :)
Hey, sorry for not answering you, but how should I’ve known that you’ve written here? ;) Probably you want to mail me?
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
awesome dude. thanks :D
Welcome ;)
Next time I feel my weekend is boring, I am adding ASCII art to the status n animate it :)
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
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
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.
Wow, I am more than surprised how many people are finding this useful! :)
Thanx! :)
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! ;)
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 ;)
Very useful script! Thanks for taking the time to do it 3 years ago! :~)
Great work! Exactly what I was looking for. :D