lain/imap.md

77 lines
2.5 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-11 19:51:45 +02:00
**Please be warned**: this is a temporary solution, I am working on something much more solid.
2013-09-10 23:26:48 +02:00
---
2013-09-10 23:25:32 +02:00
2013-09-07 14:11:42 +02:00
Shows mail status in a textbox over IMAP protocol.
2013-09-07 12:24:05 +02:00
New mails are notified through a notification like this:
+---------------------------------------------------+
| +---+ |
| |\ /| donald@disney.org has 3 new messages |
| +---+ |
| Latest From: Mickey Mouse <boss@disney.org> |
| Subject: Re: pay raise |
| |
| Not after what you did yesterday. |
| Daisy told me everything [...] |
| |
+---------------------------------------------------+
Text will be cut if the mail is too long.
myimapcheck = lain.widgets.imap(args)
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
`encoding` | Mail character encoding | string | autodetected
2013-09-07 12:24:05 +02:00
`maxlen` | Maximum chars to display in notification | int | 200
`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-10 23:17:21 +02:00
`settings` can use the string `mailcount`, whose possible values are:
- "0"
- "invalid credentials"
- string number
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. Default definition:
notification _preset = {
icon = lain/icons/mail.png,
timeout = 8,
position = "top_left"
}
### output
2013-09-07 12:26:19 +02:00
2013-09-10 23:17:21 +02:00
A textbox.