So for a long time I had the current song from XMMS in my GAIM info, but I switched to amaroK and I needed to do something else. So I got the AutoProfile Plugin and it can run any program and use the output from that. I suggest setting up the program as a cron job and having AutoProfile reading from a file as that won't cause it to take a long time if you want perl to do something that takes a while. Anyway, after browsing around on CPAN through the Acme namespace a bit, I came up with this simple and fun info message:
#!/usr/bin/perl use strict; #use Acme::Terror::UK; use Acme::Terror; use DCOP; my $t = Acme::Terror->new(); #my $s = Acme::Terror::UK->new(); my $dcop = DCOP->new(); #my $uLevel = $s->fetch(); my $level = $t->fetch(); my $current_song = $dcop->run( 'amarok player nowPlaying' ); if ($dcop->run('amarok player status') == 1) { $current_song = "$current_song [paused]"; } if ($current_song) { print "I am currently listening to: $current_song\n"; } print "Stay informed! The current terrorist threat level in the US is +: $level\n"; #print "Also: The current terrorist threat level in the UK is: $uLevel +\n";
The UK stuff is commented out because the server seems to be down. Probably because of the recent unfortunate events in that area. Either way, I hope someone finds this cool and useful. I certainly dig it!

Note: Because getting the terror level seems to be taking a while I had this delegated to a cron job. I can't figure out how to get the information from amaroK via cron, supposedly because of user permission issues. If anyone figures out a way, let me know. Update: I figured out what my problem was with getting the music via cron. The DCOP module uses kde-config to locate the dcop binary, but if kde-config is not in your path, it will just choke. I added a PATH variable to my cron and that fixed everything. Now hopefully you will all have the current song in your gaim info as well!

Replies are listed 'Best First'.
Re: Dynamic GAIM Info
by Tanktalus (Canon) on Aug 12, 2006 at 14:04 UTC

    I'm betting that DCOP uses X server commands to connect and communicate. In that case, even your own user running under cron may not have authority to connect due to lack of X authority. The easiest way around that that I know of is to actually run under X. Try using kcron - I'm not sure, but it may run under X, which would give anything it runs the authority to communicate with the local X server.

    (I'm guessing that amaroK is a KDE application, that's why I'm suggesting kcron. If you're running gnome, you may want to look for a gnome equivalent, although kcron should work just as well under gnome as it does under kde: it should either work in both places or neither.)

      I think you are right. I looked at kcron, but it looks like it is just a frontend to cron. I think the best (and more efficient anyway) solution would be to have amaroK run the program that outputs to a file every time a song changes. As opposed to running every one minute. Thanks for the help anyway!
Re: Dynamic GAIM Info
by f00li5h (Chaplain) on Aug 12, 2006 at 05:34 UTC
    Hi there,

    I imagine that you'd only need to make sure that you run the GAIM script as the same user as the terror level caching user.

    so from cron, you write the terror level to /tmp/terror, and then pick that up later from the GAIM plugin, or you could just make /tmp/terror world readable (then anyone on your box could use the script without having to get their own terror file.

    in other news: first post -HTH

    will: do{ perl programing } for ($cash) ;