-
Notifications
You must be signed in to change notification settings - Fork 210
Widgets
Every lain widget is a table.
A lain widget is generated by a function
.
The function
signature, input and output arguments can be found in the related wiki entry.
Every lain widget contains a wibox.widget
, which is updated by a timed function. To access the widget, use the field widget
, to access the timed function, use the field update
. Some lain widgets may also have an icon
field, which is a wibox.widget.imagebox
, and/or a timer
field, which is the gears.timer
on update
.
Every function
may take either a table or a list of variables as input.
If the input is a table, you must define a function variable called settings
in it. There you will be able to define widget
appearance.
For instance, if widget
is a textbox, to markup it call widget:set_markup(...)
within settings
.
In the scope of settings
you can use predefined arguments, which are specified in the wiki entries.
Example of a lain widget:
local cpu = lain.widget.cpu {
settings = function()
widget:set_markup("Cpu " .. cpu_now.usage)
end
}
-- to access the widget: cpu.widget
Given the asynchronous nature of these widgets, be sure to use a defensive programming style when you write your configuration. You can find various examples of this in awesome-copycats.