Permalink
Browse files

Lite version of the same script with less features.

  • Loading branch information...
1 parent a735cf7 commit 463f5ef220f1a4d5294f671797c83683159a7cd7 @Gurpartap committed Jun 8, 2011
Showing with 43 additions and 1 deletion.
  1. +42 −0 g15-gmail-notifier-lite.py
  2. +1 −1 g15-gmail-notifier.py
View
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+# (c) 2008 Gurpartap Singh — http://gurpartap
+
+import subprocess
+import webbrowser
+
+username = "you@gmail.com"
+password = "lolphp"
+
+try:
+ import libgmail
+except ImportError:
+ print "libgmail is missing."
+ raise SystemExit(1)
+
+mail = libgmail.GmailAccount(username, password)
+
+print "Logging in using username %s..." % username
+
+try:
+ mail.login()
+except libgmail.GmailLoginFailure:
+ print "Login failed!\nCheck your username or password and make sure you are connected to the internet."
+ raise SystemExit(1)
+else:
+ print "Logged in successfully."
+
+if mail.getUnreadMsgCount("inbox"):
+ folder = mail.getUnreadMessages("inbox")
+ if len(folder) > 1:
+ title = "%d Unread Messages!" % len(folder)
+ msg = "Do you want to goto Inbox now?"
+ thread_id = ""
+ else:
+ title = "New e-mail received!"
+ # The following will mark your message are "read".
+ #msg = "%s: %s" % folder[0][0].sender, folder[0][0].subject
+ msg = "Read the message now?"
+ thread_id = "/" + folder[0].id
+
+ if subprocess.call(["g15message", "-c", "-y", "-t", title, msg]):
+ webbrowser.open_new_tab("http://mail.google.com/mail/#inbox%s" % thread_id)
View
@@ -48,7 +48,7 @@ def main(username, password, label, delay):
try:
import libgmail
except ImportError:
- print "\033[31m" + " [31mlibgmail is missing. Get compliant package from http://myzonelabs.com/" + "\033[0;0m"
+ print "\033[31m" + " [31mlibgmail is missing." + "\033[0;0m"
return 1
try:

0 comments on commit 463f5ef

Please sign in to comment.