#!/usr/bin/python
# -*- coding: utf-8 -*- 
#
# Licensed under the GNU General Public License, version 3.
# See the file http://www.gnu.org/licenses/gpl-3.0.txt

import libgmail
import sys, os, time
os.system("tuxd& tuxttsd&")
sys.path.append('/opt/tuxdroid/api/python')
from tux import *

login = sys.argv[1]
password = sys.argv[2]

try:
    ga = libgmail.GmailAccount(login , password)
    ga.login()
    email_count = ga.getUnreadMsgCount()    
    while True:
        new_count = ga.getUnreadMsgCount()
        if new_count > 0:
            tux.cmd.eyes_open()
        else:
            tux.cmd.eyes_close()
        if new_count > email_count:
            tux.tts.speak("Hey ! You've got a new email.")
        email_count = new_count        
        time.sleep(15)
finally:
    tux.destroy()
