.awesome/mail_loop_gmail.py

20 lines
529 B
Python
Raw Normal View History

2014-08-15 00:06:35 +04:00
#!/usr/bin/python
2014-08-16 15:19:58 +04:00
# Create ~/.local/share/keyrings/mail_loop_keys.py:
# gmail_login = 'username'
# gmail_password = 'password'
2014-08-15 00:06:35 +04:00
2014-08-16 15:19:58 +04:00
import imaplib,sys,os
2014-08-15 00:06:35 +04:00
2014-08-15 09:28:31 +04:00
try:
2014-08-16 15:19:58 +04:00
sys.path.insert (0, os.getenv("HOME")+"/.local/share/keyrings")
from mail_loop_keys import gmail_login,gmail_password
2014-08-15 09:28:31 +04:00
M=imaplib.IMAP4_SSL("imap.gmail.com", 993)
M.login(gmail_login,gmail_password)
status, counts = M.status("Inbox","(MESSAGES UNSEEN)")
unread = counts[0].split()[4][:-1]
M.logout()
print(int(unread))
except:
print("?")