Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

perl (conky) and gmail/IMAP unread message count

Shell Programming and Scripting


Tags
conky, conky monitor, gmail, imap, perl, smtp

Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 07-25-2009
gxmsgx's Unix or Linux Image
gxmsgx gxmsgx is offline
Registered User
 
Join Date: Jul 2009
Last Activity: 25 July 2010, 8:43 AM EDT
Posts: 31
Thanks: 0
Thanked 1 Time in 1 Post
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 Linux)

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:
Linux

Last edited by gxmsgx; 07-25-2009 at 10:38 AM..
The Following User Says Thank You to gxmsgx For This Useful Post:
Neo (03-31-2015)
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 09:24 AM.