Debian Codegraph @

vicious/docs/source/widgets.rst

raw
1 .. _widgets:
2
3 Officially Supported Widget Types
4 =================================
5
6 Widget types consist of worker functions that take two arguments
7 ``format`` and ``warg`` (in that order), which were previously
8 passed to :lua:func:`vicious.register`, and return a table of values
9 to be formatted by ``format``.
10
11 vicious.widgets.amdgpu
12 ----------------------
13
14 Provides GPU and VRAM usage statistics for AMD graphics cards.
15
16 Supported platforms: GNU/Linux (require ``sysfs``)
17
18 * ``warg`` (from now on will be called *argument*): card ID, e.g. ``"card0"``
19 * Returns a table with string keys: ``${gpu_usage}``, ``${mem_usage}``
20
21 vicious.widgets.bat
22 -------------------
23
24 Provides state, charge, and remaining time for a requested battery.
25
26 Supported platforms: GNU/Linux (require ``sysfs``),
27 FreeBSD (require ``acpiconf``) and OpenBSD (no extra requirements).
28
29 * Argument:
30
31 * On GNU/Linux: battery ID, e.g. ``"BAT0"``
32 * On FreeBSD (optional): battery ID, e.g. ``"batt"`` or ``"0"``
33 * On OpenBSD (optional): ``bat`` followed by battery index,
34 e.g. ``"bat0"`` or ``"bat1"`` on systems with more than one battery
35
36 * Returns an array (integer-indexed table) consisting of:
37
38 * ``$1``: State of requested battery
39 * ``$2``: Charge level in percent
40 * ``$3``: Remaining (charging or discharging) time
41 * ``$4``: Wear level in percent
42 * ``$5``: Current (dis)charge rate in Watt
43
44 vicious.contrib.cmus
45 --------------------
46
47 Provides cmus player information using ``cmus-remote``.
48
49 Supported platforms: platform independent.
50
51 * Argument: a table whose first field is the socket including host (or nil).
52 * Returns a table with string keys: ``${status}``, ``${artist}``, ``${title}``,
53 ``${duration}``, ``${file}``, ``${continue}``, ``${shuffle}``, ``${repeat}``.
54
55 vicious.widgets.cpu
56 -------------------
57
58 Provides CPU usage for all available CPUs/cores. Since this widget type give
59 CPU utilization between two consecutive calls, it is recommended to enable
60 caching if it is used to register multiple widgets (#71).
61
62 Supported platforms: GNU/Linux, FreeBSD, OpenBSD.
63
64 On FreeBSD and Linux returns an array containing:
65
66 * ``$1``: usage of all CPUs/cores
67 * ``$2``, ``$3``, etc. are respectively the usage of 1st, 2nd, etc. CPU/core
68
69 On OpenBSD returns an array containing:
70
71 * ``$1``: usage of all CPUs/cores
72
73 vicious.widgets.cpufreq
74 -----------------------
75
76 Provides freq, voltage and governor info for a requested CPU.
77
78 Supported platforms: GNU/Linux, FreeBSD.
79
80 * Argument: CPU ID, e.g. ``"cpu0"`` on GNU/Linux, ``"0"`` on FreeBSD
81 * Returns an array containing:
82
83 * ``$1``: Frequency in MHz
84 * ``$2``: Frequency in GHz
85 * ``$3``: Voltage in mV
86 * ``$4``: Voltage in V
87 * ``$5``: Governor state
88 * On FreeBSD: only the first two are supported
89 (other values will always be ``"N/A"``)
90
91 vicious.widgets.cpuinf
92 ----------------------
93
94 Provides speed and cache information for all available CPUs/cores.
95
96 Supported platforms: GNU/Linux.
97
98 Returns a table whose keys using CPU ID as a base, e.g. ``${cpu0 mhz}``,
99 ``${cpu0 ghz}``, ``${cpu0 kb}``, ``${cpu0 mb}``, ``${cpu1 mhz}``, etc.
100
101 vicious.widgets.date
102 --------------------
103
104 Provides access to Lua's ``os.date``, with optional settings for time format
105 and time offset.
106
107 Supported platforms: platform independent.
108
109 * ``format`` (optional): a `strftime(3)`_ format specification string
110 (format functions are not supported). If not provided, use the prefered
111 representation for the current locale.
112 * Argument (optional): time offset in seconds, e.g. for different a time zone.
113 If not provided, current time is used.
114 * Returns the output of ``os.date`` formatted by ``format`` *string*.
115
116 vicious.widgets.dio
117 -------------------
118
119 Provides I/O statistics for all available storage devices.
120
121 Supported platforms: GNU/Linux.
122
123 Returns a table with string keys: ``${sda total_s}``, ``${sda total_kb}``,
124 ``${sda total_mb}``, ``${sda read_s}``, ``${sda read_kb}``, ``${sda read_mb}``,
125 ``${sda write_s}``, ``${sda write_kb}``, ``${sda write_mb}``,
126 ``${sda iotime_ms}``, ``${sda iotime_s}``, ``${sdb1 total_s}``, etc.
127
128 vicious.widget.fanspeed
129 -----------------------
130
131 Provides fanspeed information for specified fans.
132
133 Supported platforms: FreeBSD.
134
135 * Argument: full ``sysctl`` string to one or multiple entries,
136 e.g. ``"dev.acpi_ibm.0.fan_speed"``
137 * Returns speed of specified fan in RPM, ``"N/A"`` on error
138 (probably wrong string)
139
140 vicious.widgets.fs
141 ------------------
142
143 Provides usage of disk space.
144
145 Supported platforms: platform independent.
146
147 * Argument (optional): if true includes remote filesystems, otherwise fallback
148 to default, where only local filesystems are included.
149 * Returns a table with string keys, using mount points as a base,
150 e.g. ``${/ size_mb}``, ``${/ size_gb}``, ``${/ used_mb}``, ``${/ used_gb}``,
151 ``${/ used_p}``, ``${/ avail_mb}``, ``${/ avail_gb}``, ``${/ avail_p}``,
152 ``${/home size_mb}``, etc.
153 mb and gb refer to mebibyte and gibibyte respectively.
154
155 vicious.widgets.gmail
156 ---------------------
157
158 Provides count of new and subject of last e-mail on Gmail.
159
160 Supported platform: platform independent, requiring ``curl``.
161
162 This widget expects login information in your ``~/.netrc`` file, e.g.
163 ``machine mail.google.com login user password pass``. Use your `app
164 password`_ if you can, or disable `two step verification`_
165 and `allow access for less secure apps`_.
166
167 .. caution::
168
169 Making these settings is a security risk!
170
171 * Arguments (optional): either a number or a table
172
173 * If it is a number, subject will be truncated.
174 * If it is a table whose first field is the maximum length and second field
175 is the widget name (e.g. ``"gmailwidget"``), scrolling will be used.
176
177 * Returns a table with string keys: ``${count}`` and ``${subject}``
178
179 vicious.widgets.hddtemp
180 -----------------------
181
182 Provides hard drive temperatures using the hddtemp daemon.
183
184 Supported platforms: GNU/Linux, requiring ``hddtemp`` and ``curl``.
185
186 * Argument (optional): ``hddtemp`` listening port (default: 7634)
187 * Returns a table with string keys, using hard drives as a base, e.g.
188 ``${/dev/sda}`` and ``${/dev/sdc}``.
189
190 vicious.widgets.hwmontemp
191 -------------------------
192
193 Provides name-based access to hwmon devices via sysfs.
194
195 Supported platforms: GNU/Linux
196
197 * Argument: an array with sensor name and input number
198 (optional, falling back to ``1``), e.g. ``{"radeon", 2}``
199 * Returns a table with just the temperature value: ``$1``
200 * Usage example:
201
202 .. code-block:: lua
203
204 gputemp = wibox.widget.textbox()
205 vicious.register(gputemp, vicious.widgets.hwmontemp, " $1°C", 5, {"radeon"})
206
207 vicious.widgets.mbox
208 --------------------
209
210 Provides the subject of last e-mail in a mbox file.
211
212 Supported platforms: platform independent.
213
214 * Argument: either a string or a table:
215
216 * A string representing the full path to the mbox, or
217 * Array of the form ``{path, maximum_length[, widget_name]}``.
218 If the widget name is provided, scrolling will be used.
219 * Note: the path will be escaped so special variables like ``~`` will not
220 work, use ``os.getenv`` instead to access environment variables.
221
222 * Returns an array whose first value is the subject of the last e-mail.
223
224 vicious.widgets.mboxc
225 ---------------------
226
227 Provides the count of total, old and new messages in mbox files.
228
229 Supported platforms: platform independent.
230
231 * Argument: an array full paths to mbox files.
232 * Returns an array containing:
233
234 * ``$1``: Total number of messages
235 * ``$2``: Number of old messages
236 * ``$3``: Number of new messages
237
238 vicious.widgets.mdir
239 --------------------
240
241 Provides the number of unread messages in Maildir structures/directories.
242
243 Supported platforms: platform independent.
244
245 * Argument: an array with full paths to Maildir structures.
246 * Returns an array containing:
247
248 * ``$1``: Number of new messages
249 * ``$2``: Number of *old* messages lacking the *Seen* flag
250
251 vicious.widgets.mem
252 -------------------
253
254 Provides RAM and Swap usage statistics.
255
256 Supported platforms: GNU/Linux, FreeBSD.
257
258 Returns (per platform):
259 * GNU/Linux: an array consisting of:
260
261 * ``$1``: Memory usage in percent
262 * ``$2``: Memory usage in MiB
263 * ``$3``: Total system memory in MiB
264 * ``$4``: Free memory in MiB
265 * ``$5``: Swap usage in percent
266 * ``$6``: Swap usage in MiB
267 * ``$7``: Total system swap in MiB
268 * ``$8``: Free swap in MiB
269 * ``$9``: Memory usage with buffers and cache, in MiB
270
271 * FreeBSD: an array including:
272
273 * ``$1``: Memory usage in percent
274 * ``$2``: Memory usage in MiB
275 * ``$3``: Total system memory in MiB
276 * ``$4``: Free memory in MiB
277 * ``$5``: Swap usage in percent
278 * ``$6``: Swap usage in MiB
279 * ``$7``: Total system swap in MiB
280 * ``$8``: Free swap in MiB
281 * ``$9``: Wired memory in percent
282 * ``$10``: Wired memory in MiB
283 * ``$11``: Unfreeable memory (basically active+inactive+wired) in percent
284 * ``$12``: Unfreeable memory in MiB
285
286 vicious.widgets.mpd
287 -------------------
288
289 Provides Music Player Daemon information.
290
291 Supported platforms: platform independent (required tools: ``curl``).
292
293 * Argument: an array including password, hostname and port in that order.
294 ``nil`` fields will be fallen back to default
295 (``localhost:6600`` without password).
296 * Returns a table with string keys: ``${volume}``, ``${bitrate}``,
297 ``${elapsed}`` (in seconds), ``${duration}`` (in seconds),
298 ``${Elapsed}`` (formatted as [hh:]mm:ss),
299 ``${Duration}`` (formatted as [hh:]mm:ss), ``${Progress}`` (in percentage),
300 ``${random}``, ``${repeat}``, ``${state}``, ``${Artist}``, ``${Title}``,
301 ``${Album}``, ``${Genre}`` and optionally ``${Name}`` and ``${file}``.
302
303 In addition, some common mpd commands are available as functions:
304 ``playpause``, ``play``, ``pause``, ``stop``, ``next``, ``previous``.
305 Arguments are of the same form as above, and no value is returned,
306 e.g. ``vicious.widgets.mpd.playpause()``.
307
308 vicious.widgets.net
309 -------------------
310
311 Provides state and usage statistics of network interfaces.
312
313 Supported platforms: GNU/Linux, FreeBSD.
314
315 * Argument (FreeBSD only): desired interface, e.g. ``"wlan0"``
316 * Returns (per platform):
317
318 * GNU/Linux: a table with string keys, using net interfaces as a base,
319 e.g. ``${eth0 carrier}``, ``${eth0 rx_b}``, ``${eth0 tx_b}``,
320 ``${eth0 rx_kb}``, ``${eth0 tx_kb}``, ``${eth0 rx_mb}``,
321 ``${eth0 tx_mb}``, ``${eth0 rx_gb}``, ``${eth0 tx_gb}``,
322 ``${eth0 down_b}``, ``${eth0 up_b}``, ``${eth0 down_kb}``,
323 ``${eth0 up_kb}``, ``${eth0 down_mb}``, ``${eth0 up_mb}``,
324 ``${eth0 down_gb}``, ``${eth0 up_gb}``, ``${eth1 rx_b}``, etc.
325 * FreeBSD: a table with string keys: ``${carrier}``, ``${rx_b}``, ``${tx_b}``,
326 ``${rx_kb}``, ``${tx_kb}``, ``${rx_mb}``, ``${tx_mb}``, ``${rx_gb}``,
327 ``${tx_gb}``, ``${down_b}``, ``${up_b}``, ``${down_kb}``, ``${up_kb}``,
328 ``${down_mb}``, ``${up_mb}``, ``${down_gb}``, ``${up_gb}``.
329
330 vicious.widgets.notmuch
331 -----------------------
332
333 Provides a message count according to an arbitrary Notmuch query.
334
335 Supported platforms: platform independent.
336
337 Argument: the query that is passed to Notmuch. For instance:
338 ``tag:inbox AND tag:unread`` returns the number of unread messages with
339 tag "inbox".
340
341 Returns a table with string keys containing:
342
343 * ``${count}``: the count of messages that match the query
344
345
346 vicious.widgets.org
347 -------------------
348
349 Provides agenda statistics for Emacs org-mode.
350
351 Supported platforms: platform independent.
352
353 * Argument: an array of full paths to agenda files,
354 which will be parsed as arguments.
355 * Returns an array consisting of
356
357 * ``$1``: Number of tasks you forgot to do
358 * ``$2``: Number of tasks for today
359 * ``$3``: Number of tasks for the next 3 days
360 * ``$4``: Number of tasks to do in the week
361
362 vicious.widgets.os
363 ------------------
364
365 Provides operating system information.
366
367 Supported platforms: platform independent.
368
369 Returns an array containing:
370
371 * ``$1``: Operating system in use
372 * ``$2``: Release version
373 * ``$3``: Username
374 * ``$4``: Hostname
375 * ``$5``: Available system entropy
376 * ``$6``: Available entropy in percent
377
378 vicious.widgets.pkg
379 -------------------
380
381 Provides number of pending updates on UNIX systems. Be aware that some package
382 managers need to update their local databases (as root) before showing the
383 correct number of updates.
384
385 Supported platforms: platform independent, although it requires Awesome
386 ``awful.spawn`` library for non-blocking spawning.
387
388 * Argument: distribution name, e.g. ``"Arch"``, ``"Arch C"``, ``"Arch S"``,
389 ``"Debian"``, ``"Ubuntu"``, ``"Fedora"``, ``"FreeBSD"``, ``"Mandriva"``.
390 * Returns an array including:
391
392 * ``$1``: Number of available updates
393 * ``$2``: Packages available for update
394
395 vicious.widgets.raid
396 --------------------
397
398 Provides state information for a requested RAID array.
399
400 Supported platforms: GNU/Linux.
401
402 * Argument: the RAID array ID.
403 * Returns an array containing:
404
405 * ``$1``: Number of assigned devices
406 * ``$2``: Number of active devices
407
408 vicious.widgets.thermal
409 -----------------------
410
411 Provides temperature levels of several thermal zones.
412
413 Supported platforms: GNU/Linux, FreeBSD.
414
415 * Argument (per platform):
416
417 * GNU/Linux: either a string - the thermal zone, e.g. ``"thermal_zone0"``,
418 or a table of the form ``{thermal_zone, data_source[, input_file]}``.
419 Available ``data_source``'s and corresponding default ``input_file``
420 are given in the table below. For instance, if ``"thermal_zone0"``
421 is passed, temperature would be read from
422 ``/sys/class/thermal/thermal_zone0/temp``. This widget type is confusing
423 and ugly but it is kept for backward compatibility.
424 * FreeBSD: either a full ``sysctl`` path to a thermal zone, e.g.
425 ``"hw.acpi.thermal.tz0.temperature"``, or a table with multiple paths.
426
427 * Returns (per platform):
428
429 * GNU/Linux: an array whose first value is the requested temperature.
430 * FreeBSD: a table whose keys are provided paths thermal zones.
431
432 =============== ======================== ======================
433 ``data_source`` Path Default ``input_file``
434 =============== ======================== ======================
435 ``"sys"`` /sys/class/thermal/ ``"temp"``
436 ``"core"`` /sys/devices/platform/ ``"temp2_input"``
437 ``"hwmon"`` /sys/class/hwmon/ ``"temp1_input"``
438 ``"proc"`` /proc/acpi/thermal_zone/ ``"temperature"``
439 =============== ======================== ======================
440
441 vicious.widgets.uptime
442 ----------------------
443
444 Provides system uptime and load information.
445
446 Supported platforms: GNU/Linux, FreeBSD.
447
448 Returns an array containing:
449
450 * ``$1``: Uptime in days
451 * ``$2``: Uptime in hours
452 * ``$3``: Uptime in minutes
453 * ``$4``: Load average in the past minute
454 * ``$5``: Load average in the past 5 minutes
455 * ``$6``: Load average in the past 15 minutes
456
457 vicious.widgets.volume
458 ----------------------
459
460 Provides volume levels and state of requested mixers.
461
462 Supported platforms: GNU/Linux (requiring ``amixer``), FreeBSD.
463
464 * Argument (per platform):
465
466 * GNU/Linux: either a string containing the ALSA mixer control
467 (e.g. ``"Master"``) or a table including command line arguments
468 to be passed to `amixer(1)`_, e.g. ``{"PCM", "-c", "0"}``
469 or ``{"Master", "-D", "pulse"}``
470 * FreeBSD: the mixer control, e.g. ``"vol"``
471
472 * Returns an array consisting of (per platform):
473
474 * GNU/Linux: ``$1`` as the volume level and ``$2`` as the mute state of
475 the requested control
476 * FreeBSD: ``$1`` as the volume level of the *left* channel, ``$2`` as the
477 volume level of the *right* channel and ``$3`` as the mute state of the
478 desired control
479
480 vicious.widgets.weather
481 -----------------------
482
483 Provides weather information for a requested station.
484
485 Supported platforms: any having Awesome and ``curl`` installed.
486
487 * Argument: the ICAO station code, e.g. ``"LDRI"``
488 * Returns a table with string keys: ``${city}``, ``${wind}``, ``${windmph}``,
489 ``${windkmh}``, ``${sky}``, ``${weather}``, ``${tempf}``, ``${tempc}``,
490 ``${humid}``, ``${dewf}``, ``${dewc}`` and ``${press}``, ``${when}``
491
492 vicious.widgets.wifi
493 --------------------
494
495 Provides wireless information for a requested interface.
496
497 Supported platforms: GNU/Linux.
498
499 * Argument: the network interface, e.g. ``"wlan0"``
500 * Returns a table with string keys: ``${ssid}``, ``${mode}``,
501 ``${chan}``, ``${rate}`` (Mb/s), ``${freq}`` (MHz),
502 ``${txpw}`` (transmission power, in dBm), ``${sign}`` (signal level),
503 ``${link}`` and ``${linp}`` (link quality per 70 and per cent)
504
505 vicious.widgets.wifiiw
506 ----------------------
507
508 Provides wireless information for a requested interface (similar to
509 vicious.widgets.wifi, but uses ``iw`` instead of ``iwconfig``).
510
511 Supported platforms: GNU/Linux.
512
513 * Argument: the network interface, e.g. ``"wlan0"``
514 * Returns a table with string keys: ``${bssid}``, ``${ssid}``,
515 ``${mode}``, ``${chan}``, ``${rate}`` (Mb/s), ``${freq}`` (MHz),
516 ``${linp}`` (link quality in percent),
517 ``${txpw}`` (transmission power, in dBm)
518 and ``${sign}`` (signal level, in dBm)
519
520 .. _strftime(3): https://linux.die.net/man/3/strftime
521 .. _app password: https://support.google.com/accounts/answer/185833?hl=en
522 .. _two step verification: https://support.google.com/accounts/answer/1064203
523 .. _allow access for less secure apps:
524 https://www.google.com/settings/security/lesssecureapps
525 .. _amixer(1): https://linux.die.net/man/1/amixer