How to display your tweets using Growl!
on November 15th, 2008 Posted in Apple | Hacks/Mods | Tips 0
Growl has always been a great app. It simplifies everything I do, and now, it’s becoming even more useful
Richard Stelling of EchoTech put together this deceivingly simply How-To for integrating Twitter with Growl.. It involves some terminal work but please don’t let that scare you away. Its very simply copy and paste stuff.
1. Installing the Modules
You will need only 3 modules Mac::Growl, Net::Twitter and Date::Format, if your lucky Date::Format might even be already installed. Type the following commands into terminal.
$ sudo perl -MCPAN -e shell
This will launch a CPAN command line session to install the modules type (at the prompt):
> install Mac::Growl
Agree to any dependancies, when it done type:
> install Net::Twitter
Again agree to all dependancies, and lastly:
> install Date::Format
> exit
If you had any problems it may be because You need Apple’s Development tools installed, these are a free download form Apple. Please leave any problems in the comments.
2. Coding
Now for the code, just copy the following into a empty text file and save as some thing sensible like growl_tweet.pl:
#! /usr/bin/perl -wT
use Mac::Growl ':all';
use Net::Twitter;
use Date::Format;
my $app = 'Growl/Twitter';
my @names = ('New Tweet');
RegisterNotifications($app, \@names, [$names[0]]);
my $tweet = Net::Twitter->new( username=>'##REPLACE WITH USERNAME##',
password=>'##REPLACE WITH PASSWORD##' );
my $last_id = undef;
my $switch = 0;
while(1)
{
my @tt = ();
if($last_id)
{
@tt = $tweet->friends_timeline({count => 200, since_id => $last_id });
}
else
{
@tt = $tweet->friends_timeline({count => 5 });
}
foreach my $t (@{$tt[0]})
{
if(!$switch) { $last_id = $t->{id}; $switch++; };
PostNotification($app, $names[0], $t->{user}{screen_name}, $t->{text});
printf("%s: %s\n", $t->{user}{screen_name}, $t->{text});
print "sleep 4\n";
sleep(4);
}
$switch = 0;
print "sleep 37\n"; sleep(37); } exit;
3. Running
Now, simply run the script:
$ perl ./growl_tweet.pl
And bingo! All your tweets appear! Leave a comment if it works and especially if it doesn’t – if there is enough interest I might consider adding features and real installer!
If you don’t wanna code the last part you can just download the script that Richard already made(Note: you must still do step 1) Growl-Twitter_code.pl
Thanks again to EchoTech and Richard Stelling.
Tweet