MyMail icon added
This commit is contained in:
parent
a841ef8588
commit
e94a80e551
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# Create credentials.py with mymail_login, mymail_password, mymail_server, mymail_port variables
|
||||
|
||||
import imaplib,ssl
|
||||
|
||||
# http://stackoverflow.com/questions/9713055/certificate-authority-for-imaplib-and-poplib-python
|
||||
import imaplib,ssl
|
||||
def IMAP_starttls(self, keyfile=None, certfile=None,cert_reqs=ssl.CERT_NONE,ca_certs=None):
|
||||
if not 'STARTTLS' in self.capabilities:
|
||||
raise self.error("STARTTLS extension not supported by server.")
|
||||
(resp, reply) = self._simple_command("STARTTLS")
|
||||
self.sock = ssl.wrap_socket(self.sock, keyfile, certfile,cert_reqs=cert_reqs,ca_certs=ca_certs)
|
||||
self.file = self.sock.makefile('rb')
|
||||
|
||||
imaplib.IMAP4.__dict__['starttls']=IMAP_starttls
|
||||
imaplib.Commands['STARTTLS']=('NONAUTH',)
|
||||
|
||||
# read credentials
|
||||
from credentials import mymail_server,mymail_port,mymail_login,mymail_password
|
||||
|
||||
M=imaplib.IMAP4(mymail_server, mymail_port)
|
||||
M.starttls()
|
||||
M.login(mymail_login,mymail_password)
|
||||
|
||||
status, counts = M.status("Inbox","(MESSAGES UNSEEN)")
|
||||
|
||||
unread = counts[0].split()[4][:-1]
|
||||
|
||||
print(int(unread))
|
||||
|
||||
M.logout()
|
23
rc.lua
23
rc.lua
|
@ -222,6 +222,26 @@ mytasklist.buttons = awful.util.table.join(
|
|||
if client.focus then client.focus:raise() end
|
||||
end))
|
||||
|
||||
-- My MyMail updater widget
|
||||
function mymail_count()
|
||||
os.execute("~/.config/awesome/mymail_unread.py > ~/.mymail_count")
|
||||
local f = io.open(os.getenv("HOME") .. "/.mymail_count")
|
||||
local l = nil
|
||||
if f ~= nil then
|
||||
l = f:read()
|
||||
else
|
||||
l = "?"
|
||||
end
|
||||
f:close()
|
||||
return l
|
||||
end
|
||||
mymail_mail = wibox.widget.textbox( mymail_count() )
|
||||
mymail_mail.timer = timer{timeout=60}
|
||||
mymail_mail.timer:connect_signal("timeout", function () mymail_mail:set_text ( mymail_count() ) end)
|
||||
mymail_mail.timer:start()
|
||||
mymailicon = wibox.widget.imagebox()
|
||||
mymailicon:set_image(beautiful.widget_mymail)
|
||||
|
||||
-- My GMail updater widget
|
||||
function gmail_count()
|
||||
os.execute("~/.config/awesome/gmail_unread.py > ~/.gmail_count")
|
||||
|
@ -294,6 +314,9 @@ for s = 1, screen.count() do
|
|||
|
||||
right_layout:add(spacer)
|
||||
right_layout:add(mymailicon)
|
||||
right_layout:add(mymail_mail)
|
||||
myslash = wibox.widget.textbox("+")
|
||||
right_layout:add(myslash)
|
||||
right_layout:add(gmail_mail)
|
||||
|
||||
right_layout:add(spacer)
|
||||
|
|
Loading…
Reference in New Issue