From bf3a9ba5efb874ad6370a3083afd409361e2912a Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Wed, 25 Jan 2017 21:06:20 +0100 Subject: [PATCH] imap: password can now be a string, a table or a function to execute --- helpers.lua | 6 +++--- widgets/imap.lua | 7 ++++++- wiki | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/helpers.lua b/helpers.lua index e65e3fb..0305722 100644 --- a/helpers.lua +++ b/helpers.lua @@ -177,10 +177,10 @@ function helpers.spairs(t) end end --- create a textbox with no spacing issues +-- create a lain textbox function helpers.make_widget_textbox() - local w = wibox.widget.textbox() - return setmetatable({ widget = w }, { __index = w }) + local w = { widget = wibox.widget.textbox() } + return setmetatable(w, { __index = w.widget }) end -- }}} diff --git a/widgets/imap.lua b/widgets/imap.lua index 4be63dd..770a1bc 100644 --- a/widgets/imap.lua +++ b/widgets/imap.lua @@ -11,6 +11,7 @@ local naughty = require("naughty") local wibox = require("wibox") local string = { format = string.format, gsub = string.gsub } +local type = type local tonumber = tonumber local setmetatable = setmetatable @@ -37,7 +38,11 @@ local function worker(args) helpers.set_map(mail, 0) if not is_plain then - helpers.async(password, function(f) password = f:gsub("\n", "") end) + if type(password) == "string" or type(password) == "table" then + helpers.async(password, function(f) password = f:gsub("\n", "") end) + elseif type(password) == "function" then + local p = password() + end end function update() diff --git a/wiki b/wiki index f086b95..0af22b8 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit f086b95e51c31b6fc1fda4591aa8eaf587cc064f +Subproject commit 0af22b80f8dda896a0c8fefd5c7e52413294967d -- 2.39.5