#!/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!
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
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.)
perlmonks.org content © perlmonks.org and f00li5h, frew, Tanktalus
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03