perl (conky) and gmail/IMAP unread message count | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

perl (conky) and gmail/IMAP unread message count

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 07-25-2009
gxmsgx's Avatar
gxmsgx gxmsgx is offline
Registered User
 
Join Date: Jul 2009
Last Activity: 25 July 2010, 8:43 AM EDT
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
perl (conky) and gmail/IMAP unread message count

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

Code:
#!/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:
Code:
* * * * * ~/scripts/gimap.pl > ~/.email/gimap.ct

on conky file configuration (~/.conky/conky.conf):
Code:
${color1}E-mail: ${color2}gmail ${color1}(imap): ${color3}${execi 20 cat ~/.email/gimap.ct} ${color2}new

conky screenshot:

Last edited by gxmsgx; 07-25-2009 at 10:38 AM..
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Shell script to manipulate a message count for the same IP @ diff session gobinath Shell Programming and Scripting 1 05-28-2008 03:13 PM
fetchmail imap gmail certificate c19h28O2 UNIX for Dummies Questions & Answers 13 03-11-2008 09:45 PM
Mark messages as unread Rylann UNIX for Dummies Questions & Answers 1 01-24-2005 10:08 AM



All times are GMT -4. The time now is 05:25 PM.