- local args = args or {}
-
- local server = args.server
- local mail = args.mail
- local password = args.password
-
- local port = args.port or "993"
- local timeout = args.timeout or 60
- local encoding = args.encoding or nil
- local maxlen = args.maxlen or 200
- local is_plain = args.is_plain or false
- local settings = args.settings or function() end
-
- local checkmail = helpers.scripts_dir .. "checkmail"
-
- helpers.set_map(mail, true)
- helpers.set_map(mail .. " count", "0")
-
- if not is_plain
- then
- if not imap.stored
- then
- local f = io.popen(password)
- password = f:read("*all"):gsub("\n", ""):gsub("\r", "")
- f:close()
- imap.stored = password
- else
- password = imap.stored
+ local imap = { widget = wibox.widget.textbox() }
+ local args = args or {}
+ local server = args.server
+ local mail = args.mail
+ local password = args.password
+ local port = args.port or 993
+ local timeout = args.timeout or 60
+ local is_plain = args.is_plain or false
+ local followtag = args.followtag or false
+ local settings = args.settings or function() end
+
+ local head_command = "curl --connect-timeout 3 -fsm 3"
+ local request = "-X 'SEARCH (UNSEEN)'"
+
+ if not server or not mail or not password then return end
+
+ helpers.set_map(mail, 0)
+
+ if not is_plain then
+ 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()