My configuration files for Debian/Ubuntu applications
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Widgets.md 2.4 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Usage
  2. Every lain widget is a table.
  3. A lain widget is generated by a `function`.
  4. The `function` signature, input and output arguments can be found in the [related wiki entry](https://github.com/lcpz/lain/wiki/Widgets#index).
  5. 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`.
  6. Every `function` may take either a table or a list of variables as input.
  7. 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.
  8. For instance, if `widget` is a textbox, to markup it call `widget:set_markup(...)` within `settings`.
  9. In the scope of `settings` you can use predefined arguments, which are specified in the wiki entries.
  10. Example of a lain widget:
  11. ```lua
  12. local cpu = lain.widget.cpu {
  13. settings = function()
  14. widget:set_markup("Cpu " .. cpu_now.usage)
  15. end
  16. }
  17. -- to access the widget: cpu.widget
  18. ```
  19. Given the asynchronous nature of these widgets, be sure to use a [defensive programming](https://github.com/lcpz/lain/issues/451#issuecomment-615450523) style when you write your configuration. You can find various examples of this in [awesome-copycats](https://github.com/lcpz/awesome-copycats).
  20. # Index
  21. - [alsa](https://github.com/lcpz/lain/wiki/alsa)
  22. - [alsabar](https://github.com/lcpz/lain/wiki/alsabar)
  23. - [bat](https://github.com/lcpz/lain/wiki/bat)
  24. - [cal](https://github.com/lcpz/lain/wiki/cal)
  25. - [cpu](https://github.com/lcpz/lain/wiki/cpu)
  26. - [fs](https://github.com/lcpz/lain/wiki/fs)
  27. - [imap](https://github.com/lcpz/lain/wiki/imap)
  28. - [mem](https://github.com/lcpz/lain/wiki/mem)
  29. - [mpd](https://github.com/lcpz/lain/wiki/mpd)
  30. - [net](https://github.com/lcpz/lain/wiki/net)
  31. - [pulse](https://github.com/lcpz/lain/wiki/pulse)
  32. - [pulsebar](https://github.com/lcpz/lain/wiki/pulsebar)
  33. - [sysload](https://github.com/lcpz/lain/wiki/sysload)
  34. - [temp](https://github.com/lcpz/lain/wiki/temp)
  35. - [weather](https://github.com/lcpz/lain/wiki/weather)
  36. ## User contributions
  37. - [moc](https://github.com/lcpz/lain/wiki/moc)
  38. - [redshift](https://github.com/lcpz/lain/wiki/redshift)
  39. - [task](https://github.com/lcpz/lain/wiki/task)
  40. - [tp_smapi](https://github.com/lcpz/lain/wiki/tp_smapi)