Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import feedparser, pynotify
- checkerFile = '.checker'
- def checkLast(current): # Checks if the email count is the same as last time (no NEW email)
- f = open(checkerFile, 'r')
- last = f.read();
- f.close()
- if last == current:
- return True
- else:
- f = open(checkerFile, 'w')
- f.write(current)
- f.close()
- return False
- try:
- count = g.feed.fullcount # Putting the count into a variable
- except Exception: # If there is an Exception the program exits
- exit()
- if count == '0': # No need to notify me if there is no email
- checkLast(count) # but still want to update the checker file
- else:
- if checkLast(count): # If the email count is the same as was saved in the text file last, there's no new email
- pass
- else:
- pynotify.init("summary-body") # Setting up the notification
- if count == "1":
- n = pynotify.Notification("GMail", "{0} new email".format(count))
- else:
- n = pynotify.Notification("GMail", "{0} new emails".format(count))
- n.show() # Displaying the notification
Advertisement
Add Comment
Please, Sign In to add comment