X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/31c8cd320082db6d9ed48916e4fcc34a03c7effa..782da3605278f67cc13fbd408324aaf3b86a7eba:/Widgets.md?ds=inline diff --git a/Widgets.md b/Widgets.md index 86c1f46..981e4e1 100644 --- a/Widgets.md +++ b/Widgets.md @@ -1,10 +1,29 @@ Every widget is output by a `function`. -Unless otherwise expressly noted, `function` returns a `wibox.widget.textbox`. +For some widgets, `function` returns a `wibox.widget.textbox`, for others a table to be used for notification and update purposes. -We say this because, for some widget, `function` return a table to be used for notification and update purposes. +Every widget may take either a table or a list of variables as argument. -Almost all widgets can be set by an input function called `settings`: you can markup textboxes and do other customizations within it. +If it takes a table, you have to define a function variable called `settings` in it, in order to make your customizations. + +To markup the textbox, call `widget:set_markup(...)` within `settings`. + +You can feed `set_markup` with predefined arguments, see the sections for all the details. + +`widget` is a textbox, so you can threat it like any other `wibox.widget.textbox`. + +Here follows an example: + + mycpu = lain.widgets.cpu({ + timeout = 4, + settings = function() + widget:set_markup("Cpu " .. cpu_now.usage) + end + }) + +If you want to see more complex applications, check [awesome-copycats](https://github.com/copycat-killer/awesome-copycats). + +--- - [alsa](https://github.com/copycat-killer/lain/wiki/alsa) - [alsabar](https://github.com/copycat-killer/lain/wiki/alsabar)