Update with pass

This commit is contained in:
Thomas Forgione 2021-11-16 18:06:38 +01:00
parent 3719d589b1
commit b0530350e8
2 changed files with 32 additions and 21 deletions

View File

@ -2,6 +2,7 @@
import imaplib
import email
import sys
try:
import credentials

View File

@ -16,6 +16,36 @@ email_icon:set_image(path_to_icons .. "/mail-mark-new.png")
local previous_value = 0
local password1 = ''
local password2 = ''
local password3 = ''
awful.spawn.easy_async_with_shell('pass web/mail.ovh.com; pass web/webmail.gandi.net; pass web/inp-toulouse.fr;', function(stdout)
s = split(stdout, '\n')
password1 = s[1]
password2 = s[2]
password3 = s[3]
watch(
"bash -c '" .. home .. "/.config/awesome/awesome-wm-widgets/email-widget/count_unread_emails.py " .. password1 .. " " .. password2 .. " " .. password3 .. "'", 60,
function(widget, stdout, stderr, exitreason, exitcode)
local unread_emails_num = tonumber(stdout) or 0
if previous_value < unread_emails_num then
previous_value = unread_emails_num
show_emails(10)
end
email_widget:set_text(stdout)
if (unread_emails_num > 0) then
email_icon:set_image(path_to_icons .. "/mail-mark-unread.png")
elseif (unread_emails_num == 0) then
email_icon:set_image(path_to_icons .. "/mail-message-new.png")
end
end
)
end)
function split(str, delimiter)
if str == nil then
return {}
@ -34,28 +64,8 @@ function split(str, delimiter)
return ret
end
watch(
"bash -c " .. home .. "/.config/awesome/awesome-wm-widgets/email-widget/count_unread_emails.py", 60,
function(widget, stdout, stderr, exitreason, exitcode)
local unread_emails_num = tonumber(stdout) or 0
if previous_value < unread_emails_num then
previous_value = unread_emails_num
show_emails(10)
end
email_widget:set_text(stdout)
if (unread_emails_num > 0) then
email_icon:set_image(path_to_icons .. "/mail-mark-unread.png")
elseif (unread_emails_num == 0) then
email_icon:set_image(path_to_icons .. "/mail-message-new.png")
end
end
)
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 " .. password1 .. " " .. password2 .. " " .. password3,
function(stdout, stderr, reason, exit_code)
s = split(stderr, '\n')