All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
4 Licensed under GNU General Public License v2
5 * (c) 2013, Luke Bonham
9 local helpers = require("lain.helpers")
10 local async = require("lain.asyncshell")
12 local naughty = require("naughty")
13 local wibox = require("wibox")
16 local string = { format = string.format,
18 local tonumber = tonumber
20 local setmetatable = setmetatable
25 local function worker(args)
27 local args = args or {}
29 local server = args.server
30 local mail = args.mail
31 local password = args.password
33 local port = args.port or 993
34 local timeout = args.timeout or 60
35 local is_plain = args.is_plain or false
36 local followmouse = args.followmouse or false
37 local settings = args.settings or function() end
39 local head_command = "curl --connect-timeout 3 -fsm 3"
40 local request = "-X 'SEARCH (UNSEEN)'"
42 helpers.set_map(mail, 0)
46 password = helpers.read_pipe(password):gsub("\n", "")
49 imap.widget = wibox.widget.textbox('')
52 mail_notification_preset = {
53 icon = helpers.icons_dir .. "mail.png",
58 mail_notification_preset.screen = mouse.screen
61 curl = string.format("%s --url imaps://%s:%s/INBOX -u %s:%q %s -k",
62 head_command, server, port, mail, password, request)
64 async.request(curl, function(f)
65 _, mailcount = string.gsub(f, "%d+", "")
68 if mailcount ~= helpers.get_map(mail) then
73 if mailcount >= 1 and mailcount > helpers.get_map(mail)
75 if mailcount == 1 then
76 nt = mail .. " has one new message"
78 nt = mail .. " has <b>" .. mailcount .. "</b> new messages"
81 preset = mail_notification_preset,
86 helpers.set_map(mail, mailcount)
91 helpers.newtimer(mail, timeout, update, true)
93 return setmetatable(imap, { __index = imap.widget })
96 return setmetatable({}, { __call = function(_, ...) return worker(...) end })