Sunday, February 10, 2013

Check GMail script for Conky on Crunchbang Waldorf

I'm trying out Crunchbang Waldorf. I found a script for Crunchbang Statler (the previous version) that displayed the number of my new GMail messages in my Conky desktop display, but it didn't work with Waldorf. I was looking around for a simple and efficient script and eventually found one that works on the Arch Linux forum.

 I modified it a little not to show the number of emails on the server, just the number of new emails.
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import sys, imaplib

port = 993
server = ''

username = ''
passwd = 'password'

imap_server = imaplib.IMAP4_SSL(server, port)
    imap_server.login(username, passwd)
    print('?? new')
    sys.exit( 1 )

typ, data = ('Inbox', True)
if typ == 'OK':
    total = int(data[0])
    typ, data = (None, 'SEEN')
    if typ == 'OK':
        seen = len(data[0].split())
        print('{} new'.format(total - seen))

if typ != 'OK':
    print('?? new')

 Credit: rockin turtle.

No comments:

Post a Comment