Actualizacion maquina principal
[dotfiles/.git] / .config / awesome / lain / wiki / imap.md
1 ## Usage
2
3 [Read here.](https://github.com/lcpz/lain/wiki/Widgets#usage)
4
5 ### Description
6
7 Shows mails count fetching over IMAP.
8
9 ```lua
10 local myimap = lain.widget.imap(args)
11 ```
12
13 New mails are notified like this:
14
15         +--------------------------------------------+
16         | +---+                                      |
17         | |\ /| donald@disney.org has 3 new messages |
18         | +---+                                      |
19         +--------------------------------------------+
20
21 ## Input table
22
23 Required parameters are:
24
25 Variable | Meaning | Type
26 --- | --- | ---
27 `server` | Mail server | string
28 `mail` | User mail | string
29 `password` | User password | string
30
31 while the optional are:
32
33 Variable | Meaning | Type | Default
34 --- | --- | --- | ---
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
42
43 `settings` can use `imap_now` table, which contains the following non negative integers:
44
45 - `["MESSAGES"]`
46 - `["RECENT"]`
47 - `["UNSEEN"]`
48
49 example of fetch: `total = imap_now["MESSAGES"]`. For backwards compatibility, `settings` can also use `mailcount`, a pointer to `imap_now["UNSEEN"]`.
50
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:
52
53 ```lua
54 mail_notification _preset = {
55     icon = "lain/icons/mail.png",
56     position = "top_left"
57 }
58 ```
59
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.
61
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.
63
64 You can have multiple instances of this widget at the same time.
65
66 ## Password security
67
68 The reason why `is_plain` is false by default is to discourage the habit of storing passwords in plain.
69
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.
71
72 ### Using plain passwords
73
74 You can set your password in plain like this:
75
76 ```lua
77 myimapcheck = lain.widget.imap {
78     is_plain = true,
79     password = "mymailpassword",
80     -- [...]
81 }
82 ```
83
84 and you will have the same security provided by `~/.netrc`.
85
86 ### Using a password manager
87
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:
89
90 ```lua
91 myimapcheck = lain.widget.imap {
92     password = function()
93         -- do your retrieval
94         return retrieved_password, try_again
95     end,
96     -- [...]
97 }
98 ```
99
100 Where `retrieved_password` is the password retrieved from the manager, and `try_again` supports [DBus Secret Service](https://specifications.freedesktop.org/secret-service).
101
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.
103
104 ## Output table
105
106 Variable | Meaning | Type
107 --- | --- | ---
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)
112
113 The `update` function can be used to refresh the widget before `timeout` expires.
114
115 You can use `timer` to start/stop the widget as you like.