My configuration files for Debian/Ubuntu applications
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

imap.md 4.1 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. ## Usage
  2. [Read here.](https://github.com/lcpz/lain/wiki/Widgets#usage)
  3. ### Description
  4. Shows mails count fetching over IMAP.
  5. ```lua
  6. local myimap = lain.widget.imap(args)
  7. ```
  8. New mails are notified like this:
  9. +--------------------------------------------+
  10. | +---+ |
  11. | |\ /| donald@disney.org has 3 new messages |
  12. | +---+ |
  13. +--------------------------------------------+
  14. ## Input table
  15. Required parameters are:
  16. Variable | Meaning | Type
  17. --- | --- | ---
  18. `server` | Mail server | string
  19. `mail` | User mail | string
  20. `password` | User password | string
  21. `widget` | Widget to render | function | `wibox.widget.textbox`
  22. while the optional are:
  23. Variable | Meaning | Type | Default
  24. --- | --- | --- | ---
  25. `port` | IMAP port | integer | 993
  26. `timeout` | Refresh timeout (in seconds) | integer | 60
  27. `pwdtimeout` | Timeout for password retrieval function (see [here](https://github.com/lcpz/lain/wiki/imap#password-security)) | integer | 10
  28. `is_plain` | Define whether `password` is a plain password (true) or a command that retrieves it (false) | boolean | false
  29. `followtag` | Notification behaviour | boolean | false
  30. `notify` | Show notification popups | string | "on"
  31. `settings` | User settings | function | empty function
  32. `settings` can use `imap_now` table, which contains the following non negative integers:
  33. - `["MESSAGES"]`
  34. - `["RECENT"]`
  35. - `["UNSEEN"]`
  36. example of fetch: `total = imap_now["MESSAGES"]`. For backwards compatibility, `settings` can also use `mailcount`, a pointer to `imap_now["UNSEEN"]`.
  37. 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:
  38. ```lua
  39. mail_notification _preset = {
  40. icon = "lain/icons/mail.png",
  41. position = "top_left"
  42. }
  43. ```
  44. 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.
  45. 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.
  46. You can have multiple instances of this widget at the same time.
  47. ## Password security
  48. The reason why `is_plain` is false by default is to discourage the habit of storing passwords in plain.
  49. 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.
  50. ### Using plain passwords
  51. You can set your password in plain like this:
  52. ```lua
  53. myimapcheck = lain.widget.imap {
  54. is_plain = true,
  55. password = "mymailpassword",
  56. -- [...]
  57. }
  58. ```
  59. and you will have the same security provided by `~/.netrc`.
  60. ### Using a password manager
  61. 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:
  62. ```lua
  63. myimapcheck = lain.widget.imap {
  64. password = function()
  65. -- do your retrieval
  66. return retrieved_password, try_again
  67. end,
  68. -- [...]
  69. }
  70. ```
  71. Where `retrieved_password` is the password retrieved from the manager, and `try_again` supports [DBus Secret Service](https://specifications.freedesktop.org/secret-service).
  72. 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.
  73. ## Output table
  74. Variable | Meaning | Type
  75. --- | --- | ---
  76. `widget` | The widget | `wibox.widget.textbox`
  77. `update` | Update `widget` | function
  78. `timer` | The widget timer | [`gears.timer`](https://awesomewm.org/doc/api/classes/gears.timer.html)
  79. `pwdtimer` | Password retrieval timer (available only if `password` is a function)| [`gears.timer`](https://awesomewm.org/doc/api/classes/gears.timer.html)
  80. The `update` function can be used to refresh the widget before `timeout` expires.
  81. You can use `timer` to start/stop the widget as you like.