Added links to check mails
This commit is contained in:
parent
6a12e2bb9d
commit
80a590df28
|
@ -16,6 +16,24 @@ email_icon:set_image(path_to_icons .. "/mail-mark-new.png")
|
||||||
|
|
||||||
local previous_value = 0
|
local previous_value = 0
|
||||||
|
|
||||||
|
function split(str, delimiter)
|
||||||
|
if str == nil then
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
local ret = {''}
|
||||||
|
count = 1
|
||||||
|
for i = 1, string.len(str) do
|
||||||
|
local c = str:sub(i,i)
|
||||||
|
if c == delimiter then
|
||||||
|
count = count + 1
|
||||||
|
ret[count] = ''
|
||||||
|
else
|
||||||
|
ret[count] = ret[count] .. c
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return ret
|
||||||
|
end
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
"bash -c " .. home .. "/.config/awesome/awesome-wm-widgets/email-widget/count_unread_emails.py", 60,
|
"bash -c " .. home .. "/.config/awesome/awesome-wm-widgets/email-widget/count_unread_emails.py", 60,
|
||||||
function(widget, stdout, stderr, exitreason, exitcode)
|
function(widget, stdout, stderr, exitreason, exitcode)
|
||||||
|
@ -39,11 +57,26 @@ watch(
|
||||||
function show_emails(timeout)
|
function show_emails(timeout)
|
||||||
awful.spawn.easy_async_with_shell(home .. "/.config/awesome/awesome-wm-widgets/email-widget/read_unread_emails.py",
|
awful.spawn.easy_async_with_shell(home .. "/.config/awesome/awesome-wm-widgets/email-widget/read_unread_emails.py",
|
||||||
function(stdout, stderr, reason, exit_code)
|
function(stdout, stderr, reason, exit_code)
|
||||||
|
|
||||||
|
s = split(stderr, '\n')
|
||||||
|
local actions = {}
|
||||||
|
|
||||||
|
if stderr ~= '' then
|
||||||
|
for index, line in pairs(s) do
|
||||||
|
if index > 1 then
|
||||||
|
actions["Check email from account " .. tostring(index - 1)] = function ()
|
||||||
|
awful.spawn.easy_async("firefox " .. s[index - 1])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
naughty.notify{
|
naughty.notify{
|
||||||
text = stdout,
|
text = stdout,
|
||||||
title = "Unread Emails",
|
title = "Unread Emails",
|
||||||
timeout = timeout,
|
timeout = timeout,
|
||||||
width = 400,
|
width = 400,
|
||||||
|
actions = actions,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import sys
|
||||||
import imaplib
|
import imaplib
|
||||||
import email.header
|
import email.header
|
||||||
import datetime
|
import datetime
|
||||||
|
@ -13,13 +14,18 @@ def process_mailbox(mailbox, to = None):
|
||||||
rv, data = mailbox.search(None, "(UNSEEN)")
|
rv, data = mailbox.search(None, "(UNSEEN)")
|
||||||
if rv != 'OK':
|
if rv != 'OK':
|
||||||
print("No messages found!")
|
print("No messages found!")
|
||||||
return
|
return False
|
||||||
|
|
||||||
for num in data[0].split():
|
split = data[0].split()
|
||||||
|
|
||||||
|
if len(split) == 0:
|
||||||
|
return False
|
||||||
|
|
||||||
|
for num in split:
|
||||||
rv, data = mailbox.fetch(num, '(BODY.PEEK[])')
|
rv, data = mailbox.fetch(num, '(BODY.PEEK[])')
|
||||||
if rv != 'OK':
|
if rv != 'OK':
|
||||||
print("ERROR getting message", num)
|
print("ERROR getting message", num)
|
||||||
return
|
return False
|
||||||
|
|
||||||
msg = email.message_from_string(data[0][1].decode())
|
msg = email.message_from_string(data[0][1].decode())
|
||||||
|
|
||||||
|
@ -35,14 +41,8 @@ def process_mailbox(mailbox, to = None):
|
||||||
local_date = datetime.datetime.fromtimestamp(email.utils.mktime_tz(date_tuple))
|
local_date = datetime.datetime.fromtimestamp(email.utils.mktime_tz(date_tuple))
|
||||||
print("Local Date:", local_date.strftime("%a, %d %b %Y %H:%M:%S"))
|
print("Local Date:", local_date.strftime("%a, %d %b %Y %H:%M:%S"))
|
||||||
print()
|
print()
|
||||||
# with code below you can process text of email
|
|
||||||
# if msg.is_multipart():
|
|
||||||
# for payload in msg.get_payload():
|
|
||||||
# if payload.get_content_maintype() == 'text':
|
|
||||||
# print(payload.get_payload())
|
|
||||||
# else:
|
|
||||||
# print(msg.get_payload())
|
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import credentials
|
import credentials
|
||||||
|
@ -58,7 +58,8 @@ for account in credentials.accounts:
|
||||||
rv, data = mailbox.select("INBOX")
|
rv, data = mailbox.select("INBOX")
|
||||||
|
|
||||||
if rv == 'OK':
|
if rv == 'OK':
|
||||||
process_mailbox(mailbox, account.email)
|
if process_mailbox(mailbox, account.email):
|
||||||
|
print(account.link, file=sys.stderr)
|
||||||
|
|
||||||
mailbox.close()
|
mailbox.close()
|
||||||
mailbox.logout()
|
mailbox.logout()
|
||||||
|
|
2
rc.lua
2
rc.lua
|
@ -497,7 +497,7 @@ globalkeys = awful.util.table.join(
|
||||||
end, {description="Disable the second screen", group="screen control"}),
|
end, {description="Disable the second screen", group="screen control"}),
|
||||||
|
|
||||||
awful.key({modkey}, "z", function()
|
awful.key({modkey}, "z", function()
|
||||||
awful.spawn.easy_async("firefox https://hangouts.google.com https://messenger.com https://web.telegram.org https://gitter.im https://vortex-n7.slack.com/ https://nextcloud.tforgione.fr/apps/calendar", function() end)
|
awful.spawn.easy_async(option.brower .. " https://hangouts.google.com https://messenger.com https://web.telegram.org https://gitter.im https://vortex-n7.slack.com/ https://nextcloud.tforgione.fr/apps/calendar", function() end)
|
||||||
naughty.notify({title = "Starting social media"})
|
naughty.notify({title = "Starting social media"})
|
||||||
end, {description="Open social media", group="shortcuts"}),
|
end, {description="Open social media", group="shortcuts"}),
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue