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!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.