Hi all,
I use Conky monitor (Conky - Home) for my laptop and I needed a script to see the count of new messages on gmail/IMAP, then I made this small perl script
(I hope they can be useful to someone :))
gimap.pl
#!/usr/bin/perl
# gimap.pl by gxmsgx
# description: get the count of unread messages on gmail imap
use strict;
use Mail::IMAPClient;
use IO::Socket::SSL;
my $username = 'example.username'; # example.username@gmail.com
my $password = 'password123';
my $socket = IO::Socket::SSL->new(
PeerAddr => 'imap.gmail.com',
PeerPort => 993,
)
or die "socket(): $@";
my $client = Mail::IMAPClient->new(
Socket => $socket,
User => $username,
Password => $password,
)
or die "new(): $@";
if ($client->IsAuthenticated()) {
my $msgct;
$client->select("INBOX");
$msgct = $client->unseen_count||'0';
print "$msgct\n";
}
$client->logout();
on crontab:
* * * * * ~/scripts/gimap.pl > ~/.email/gimap.ct
on conky file configuration (~/.conky/conky.conf):
${color1}E-mail: ${color2}gmail ${color1}(imap): ${color3}${execi 20 cat ~/.email/gimap.ct} ${color2}new
conky screenshot: