3 [Read here.](https://github.com/lcpz/lain/wiki/Widgets#usage)
7 Shows mails count fetching over IMAP.
10 local myimap = lain.widget.imap(args)
13 New mails are notified like this:
15 +--------------------------------------------+
17 | |\ /| donald@disney.org has 3 new messages |
19 +--------------------------------------------+
23 Required parameters are:
25 Variable | Meaning | Type
27 `server` | Mail server | string
28 `mail` | User mail | string
29 `password` | User password | string
31 while the optional are:
33 Variable | Meaning | Type | Default
35 `port` | IMAP port | integer | 993
36 `timeout` | Refresh timeout (in seconds) | integer | 60
37 `pwdtimeout` | Timeout for password retrieval function (see [here](https://github.com/lcpz/lain/wiki/imap#password-security)) | integer | 10
38 `is_plain` | Define whether `password` is a plain password (true) or a command that retrieves it (false) | boolean | false
39 `followtag` | Notification behaviour | boolean | false
40 `notify` | Show notification popups | string | "on"
41 `settings` | User settings | function | empty function
43 `settings` can use `imap_now` table, which contains the following non negative integers:
49 example of fetch: `total = imap_now["MESSAGES"]`. For backwards compatibility, `settings` can also use `mailcount`, a pointer to `imap_now["UNSEEN"]`.
51 Also, `settings` can modify `mail_notification_preset` table, which will be the preset for the naughty notifications. Check [here](https://awesomewm.org/apidoc/libraries/naughty.html#notify) for the list of variables it can contain. Default definition:
54 mail_notification _preset = {
55 icon = "lain/icons/mail.png",
60 Note that `mailcount` and `imap_now` elements are equals to 0 either if there are no new mails or credentials are invalid, so make sure that your settings are correct.
62 With multiple screens, the default behaviour is to show a visual notification pop-up window on the first screen. By setting `followtag` to `true` it will be shown on the currently focused tag screen.
64 You can have multiple instances of this widget at the same time.
68 The reason why `is_plain` is false by default is to discourage the habit of storing passwords in plain.
70 In general, when `is_plain == false`, `password` can be either a string, a table or a function: the widget will execute it asynchronously in the first two cases.
72 ### Using plain passwords
74 You can set your password in plain like this:
77 myimapcheck = lain.widget.imap {
79 password = "mymailpassword",
84 and you will have the same security provided by `~/.netrc`.
86 ### Using a password manager
88 I recommend to use [spm](https://notabug.org/kl3/spm) or [pass](https://www.passwordstore.org). In this case, `password` has to be a function. Example stub:
91 myimapcheck = lain.widget.imap {
94 return retrieved_password, try_again
100 Where `retrieved_password` is the password retrieved from the manager, and `try_again` supports [DBus Secret Service](https://specifications.freedesktop.org/secret-service).
102 The process flow is that the first `password()` call spawns the unlock prompt, then the second call retrieves the password. [Here](https://gist.github.com/lcpz/1854fc4320f4701957cd5309c8eed4a6) is an example of `password` function.
106 Variable | Meaning | Type
108 `widget` | The widget | `wibox.widget.textbox`
109 `update` | Update `widget` | function
110 `timer` | The widget timer | [`gears.timer`](https://awesomewm.org/doc/api/classes/gears.timer.html)
111 `pwdtimer` | Password retrieval timer (available only if `password` is a function)| [`gears.timer`](https://awesomewm.org/doc/api/classes/gears.timer.html)
113 The `update` function can be used to refresh the widget before `timeout` expires.
115 You can use `timer` to start/stop the widget as you like.