Thread: Gmail Notifier
View Single Post
Old Dec 23rd, 2004, 1:17 PM   #1
Lance
Programmer
 
Lance's Avatar
 
Join Date: Oct 2004
Location: Chicago, IL USA
Posts: 74
Rep Power: 4 Lance is on a distinguished road
Send a message via AIM to Lance
So I use GeekTool (an app that let's me print command output right onto my root window, like root-tail and I wanted to have a simple notifier. I don't want a notifier that takes up menubar space on my already-small 12" screen, and they launch a web browser anyways, while I use Mail.app for POP3 Gmail. So I wrote some simple code for GeekTool:

print "G" if `curl -su <USER>:<PASSWORD> https://gmail.google.com/gmail/feed/atom` =~ /<entry>/

You can then just set GeekTool to run the file containing this command, or use perl -e to execute it right from GeekTool. Same with root-tail, I suppose.

Why did I post this? I have no clue, it's just interesting. A snipplet of code that others can probably use to their advantage, or even get more creative with it.

But there is also a POP3 version, if you like that more:

#!/usr/bin/perl
use Mail::POP3Client;

$pop = new Mail::POP3Client( 
 * * * *USER * * => $ENV{GMAIL_USER},
 * * * *PASSWORD => $ENV{GMAIL_PASS},
 * * * *HOST * * => "smtp.gmail.com",
 * * * *PORT * * => 995,
 * * * *USESSL * => 'true', *
 * * * *);
 
my $count = $pop->Count;
my $plural = $count == 1 ? [ 'is', '' ] : [ 'are', 's' ];

print "$ENV{GMAIL_USER}: There $$plural[0] $count" .
 *" message$$plural[1]\n";
 * * * *
$pop->Close();

It was found at the O'Reilly's Developer Weblog, if you're curious.

Anyone got other spiffy ideas on how to implement unobtrusive Gmail notifiers?

</randomRant>
__________________
/* LANCE */
C++;  /* this makes C bigger but returns the old value */
char *site = "slackwise.net",
     *home = "lance.slackwise.net",
     *pics = "flickr.com/photos/slackwise";
Lance is offline   Reply With Quote