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")
11 local naughty = require("naughty")
12 local wibox = require("wibox")
14 local io = { popen = io.popen }
15 local string = { format = string.format,
17 local tonumber = tonumber
19 local setmetatable = setmetatable
24 local function worker(args)
26 local args = args or {}
28 local server = args.server
29 local mail = args.mail
30 local password = args.password
32 local port = args.port or 993
33 local timeout = args.timeout or 60
34 local is_plain = args.is_plain or false
35 local settings = args.settings or function() end
37 local head_command = "curl --connect-timeout 1 -fsm 3"
38 local request = "-X 'SEARCH (UNSEEN)'"
40 helpers.set_map(mail, 0)
44 local f = io.popen(password)
45 password = f:read("*all"):gsub("\n", "")
49 imap.widget = wibox.widget.textbox('')
52 mail_notification_preset = {
53 icon = helpers.icons_dir .. "mail.png",
57 curl = string.format("%s --url imaps://%s:%s/INBOX -u %s:%s %s -k",
58 head_command, server, port, mail, password, request)
64 _, mailcount = string.gsub(ws, "%d+", "")
70 if mailcount >= 1 and mailcount > helpers.get_map(mail)
72 if mailcount == 1 then
73 nt = mail .. " has one new message"
75 nt = mail .. " has <b>" .. mailcount .. "</b> new messages"
78 preset = mail_notification_preset,
80 screen = client.focus and client.focus.screen or 1
84 helpers.set_map(mail, mailcount)
87 helpers.newtimer(mail, timeout, update, true)
88 return setmetatable(imap, { __index = imap.widget })
91 return setmetatable({}, { __call = function(_, ...) return worker(...) end })