lain/imap.md

60 lines
2.0 KiB
Markdown
Raw Normal View History

2013-09-07 14:34:27 +02:00
[<- widgets](https://github.com/copycat-killer/lain/wiki/Widgets)
2013-09-12 02:25:35 +02:00
Shows mail count in a textbox fetching over IMAP.
2013-09-07 12:24:05 +02:00
2013-09-12 01:17:09 +02:00
myimapcheck = lain.widgets.imap(args)
2013-09-07 12:24:05 +02:00
2013-09-12 02:25:35 +02:00
New mails are notified like this:
2013-09-07 12:24:05 +02:00
2013-09-12 01:17:09 +02:00
+--------------------------------------------+
| +---+ |
| |\ /| donald@disney.org has 3 new messages |
| +---+ |
+--------------------------------------------+
2013-09-07 12:24:05 +02:00
The function takes a table as argument. Required table parameters are:
2013-09-10 23:17:21 +02:00
Variable | Meaning | Type
--- | --- | ---
`server` | Mail server | string
`mail` | User mail | string
`password` | User password | string
2013-09-07 12:24:05 +02:00
while the optional are:
Variable | Meaning | Type | Default
--- | --- | --- | ---
`port` | IMAP port | int | 993
2013-09-10 23:17:21 +02:00
`timeout` | Refresh timeout seconds | int | 60
2013-09-07 12:24:05 +02:00
`is_plain` | Define whether `password` is a plain password (true) or a function that retrieves it (false) | boolean | false
2013-09-10 23:17:21 +02:00
`settings` | User settings | function
2013-09-09 14:03:26 +02:00
2013-09-07 12:24:05 +02:00
Let's focus better on `is_plain`.
You can just set your password like this:
args.is_plain = false
args.password = "mypassword"
2013-09-07 12:25:06 +02:00
and you'll have the same security provided by `~/.netrc`.
2013-09-07 12:24:05 +02:00
**Or** you can use a keyring, like [python keyring](https://pypi.python.org/pypi/keyring):
args.password = "keyring get password"
When `is_plain == false`, it *executes* `password` before using it, so you can also use whatever password fetching solution you want.
2013-09-12 01:17:09 +02:00
`settings` can use the value `mailcount`, an integer greater or equal to zero, and can modify `notification_preset` table, which will be the preset for the naughty notifications. Check [here](http://awesome.naquadah.org/doc/api/modules/naughty.html#notify) for the list of variables it can contain.
2013-09-10 23:17:21 +02:00
2013-09-12 01:17:09 +02:00
Default definition:
2013-09-10 23:17:21 +02:00
notification _preset = {
icon = lain/icons/mail.png,
position = "top_left"
}
2013-09-12 01:17:09 +02:00
Note that `mailcount` is 0 either if there are no new mails or credentials are invalid, so make sure you get the right settings.
2013-09-10 23:17:21 +02:00
### output
2013-09-07 12:26:19 +02:00
2013-09-10 23:17:21 +02:00
A textbox.