My configuration files for Debian/Ubuntu applications
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. ## Usage
  2. [Read here.](https://github.com/lcpz/lain/wiki/Widgets#usage)
  3. ### Description
  4. Shows the remaining time and percentage capacity of your laptop battery, as well
  5. as the current wattage. Multiple batteries are supported.
  6. Displays a notification when battery is fully charged, low, or critical.
  7. ```lua
  8. local mybattery = lain.widget.bat()
  9. ```
  10. ## Input table
  11. Variable | Meaning | Type | Default
  12. --- | --- | --- | ---
  13. `timeout` | Refresh timeout (in seconds) | integer | 30
  14. `pspath` | Power supply directory path | string | "/sys/class/power_supply/"
  15. `battery` | Single battery id | string | autodetected
  16. `batteries` | Multiple batteries id table | table of strings | autodetected
  17. `ac` | AC | string | autodetected
  18. `notify` | Show notification popups | string | "on"
  19. `full_notify` | Show a notification popup when the battery's fully charged | string | inherited value from `notify`
  20. `n_perc` | Percentages assumed for critical and low battery levels | table of integers | `{5, 15}`
  21. `settings` | User settings | function | empty function
  22. `widget` | Widget to render | function | `wibox.widget.textbox`
  23. The widget will try to autodetect `battery`, `batteries` and `ac`. If something
  24. goes wrong, you will have to define them manually. In that case, you only have
  25. to define one between `battery` and `batteries`. If you have one battery, you
  26. can either use `args.battery = "BAT*"` or `args.batteries = {"BAT*"}`, where `BAT*`
  27. is the identifier of your battery in `pspath` (do not use it as a wildcard).
  28. Of course, if you have multiple batteries, you need to use the latter option.
  29. To disable notifications, set `notify` to `"off"`.
  30. If you define `pspath`, **be sure** to not forget the final slash (/).
  31. `settings` can use the `bat_now` table, which contains the following strings:
  32. - `status`, general status ("N/A", "Discharging", "Charging", "Full");
  33. - `n_status[i]`, i-th battery status (like above);
  34. - `ac_status`, AC-plug flag (0 if cable is unplugged, 1 if plugged, "N/A" otherwise);
  35. - `perc`, total charge percentage (integer between 0 and 100 or "N/A");
  36. - `n_perc[i]`, i-th battery charge percentage (like above);
  37. - `time`, time remaining until charge if charging, until discharge if discharging (HH:MM string or "N/A");
  38. - `watt`, battery watts (float with 2 decimals);
  39. - `capacity`, remaining battery capacity in percent;
  40. - `n_capacity[i]`, i-th battery remaining capacity (like above).
  41. and can modify the following three tables, which will be the preset for the naughty notifications:
  42. * `bat_notification_charged_preset` (used if battery is fully charged and connected to AC)
  43. * `bat_notification_low_preset` (used if battery charge level <= 15)
  44. * `bat_notification_critical_preset` (used if battery charge level <= 5)
  45. Check [here](https://awesomewm.org/doc/api/libraries/naughty.html#notify) for
  46. the list of variables they can contain. Default definitions:
  47. ```lua
  48. bat_notification_charged_preset = {
  49. title = "Battery full",
  50. text = "You can unplug the cable",
  51. timeout = 15,
  52. fg = "#202020",
  53. bg = "#CDCDCD"
  54. }
  55. ```
  56. ```lua
  57. bat_notification_low_preset = {
  58. title = "Battery low",
  59. text = "Plug the cable!",
  60. timeout = 15,
  61. fg = "#202020",
  62. bg = "#CDCDCD"
  63. }
  64. ```
  65. ```lua
  66. bat_notification_critical_preset = {
  67. title = "Battery exhausted",
  68. text = "Shutdown imminent",
  69. timeout = 15,
  70. fg = "#000000",
  71. bg = "#FFFFFF"
  72. }
  73. ```
  74. ## Output table
  75. Variable | Meaning | Type
  76. --- | --- | ---
  77. `widget` | The widget | `wibox.widget.textbox`
  78. `update` | Update `widget` | function
  79. The `update` function can be used to refresh the widget before `timeout` expires.
  80. ## Note
  81. Alternatively, you can try the [`upower` recipe](https://awesomewm.org/recipes/watch).