Skip to content

Instantly share code, notes, and snippets.

@thesnapdragon
Last active August 29, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thesnapdragon/8721926 to your computer and use it in GitHub Desktop.
Save thesnapdragon/8721926 to your computer and use it in GitHub Desktop.
little Python script that writes out the count of unread gmails
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Milán Unicsovics, u.milan at gmail dot com
# usage: ./gmailToConky.py
# writes out the count of unread gmails
import requests
from xml.dom.minidom import parseString
def main():
try:
user = 'EMAILADDRESS'
password = 'PASSWORD'
response = requests.get('https://mail.google.com/mail/feed/atom'.format(user, password), auth=(user, password))
xml = parseString(response.text.encode('utf-8'))
print(xml.getElementsByTagName('fullcount')[0].childNodes[0].nodeValue)
except requests.exceptions.Timeout:
print(0)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment