Asmer imap mail widget
From awesome
This widget shows count of new mail in your mailbox, checked via python script by IMAP
Python script
#!/usr/bin/python
import imaplib
#first field is imap server, second - port (993 for gmail SSL IMAP)
M=imaplib.IMAP4_SSL("imap.gmail.com", 993)
#first field is imap login (gmail uses login with domain and '@' character), second - password
M.login("user@gmail.com","password")
status, counts = M.status("Inbox","(MESSAGES UNSEEN)")
unread = counts[0].split()[4][:-1]
if int(unread) == 0:
print " 0 "
else:
print "<span color='red'> <b>"+unread+"</b> </span>"
M.logout()
Save this script in ~/scripts/unread.py and set executable permission to it.
rc.lua configuration
--- Mail updater
mymail = widget({ type = "textbox", align = "right" })
mymail.text = " ? "
Hook (check mail every 30 seconds)
awful.hooks.timer.register(30, function ()
local f = io.open("/home/YOUR_USER/tmp/gmail")
local l = nil
if f ~= nil then
l = f:read() -- read output of command
else
l = " ? "
end
f:close()
mymail.text = l
os.execute("~/scripts/unread.py > ~/tmp/gmail &")
end)