My Awesome Config
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
529B

  1. #!/usr/bin/python
  2. # Create ~/.local/share/keyrings/mail_loop_keys.py:
  3. # gmail_login = 'username'
  4. # gmail_password = 'password'
  5. import imaplib,sys,os
  6. try:
  7. sys.path.insert (0, os.getenv("HOME")+"/.local/share/keyrings")
  8. from mail_loop_keys import gmail_login,gmail_password
  9. M=imaplib.IMAP4_SSL("imap.gmail.com", 993)
  10. M.login(gmail_login,gmail_password)
  11. status, counts = M.status("Inbox","(MESSAGES UNSEEN)")
  12. unread = counts[0].split()[4][:-1]
  13. M.logout()
  14. print(int(unread))
  15. except:
  16. print("?")