perl (conky) and gmail/IMAP unread message count


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Old 07-25-2009
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 Smilie)

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

Last edited by gxmsgx; 07-25-2009 at 10:38 AM..
This User Gave Thanks to gxmsgx For This Post:
Neo (03-31-2015)
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Find Unread Files cnrj Emergency UNIX and Linux Support 9 02-05-2014 10:18 AM
Printing a message in file without opening it in perl harpal singh Shell Programming and Scripting 2 03-12-2012 12:13 PM
shell script for conky getting errors.... krisdeniseriley Shell Programming and Scripting 8 01-06-2012 11:50 PM
CrunchBang: Conky stops updating looop Linux 0 05-02-2011 03:55 AM
Conky apps key binding so that no need to minimize the windows open to see desktop jao_madn UNIX for Advanced & Expert Users 0 03-27-2011 06:26 PM
How to see unread e-mails only in Alpine? JamesR404 UNIX for Dummies Questions & Answers 0 03-03-2011 08:21 AM
Pine continuously marks old messages as unread veepine UNIX for Dummies Questions & Answers 0 02-23-2011 03:20 PM
Does replying to your own message count as an additional post? figaro Post Here to Contact Site Administrators and Moderators 2 08-27-2010 11:17 AM
[Perl] Capture system call error message. ejdv Shell Programming and Scripting 3 08-19-2009 10:07 AM
Rotating logs in Perl without message loss w1r3d Shell Programming and Scripting 1 07-25-2009 01:43 PM
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