| 1 | Battery widget |
| 2 | ============== |
| 3 | |
| 4 | This widget is a battery monitor. It gets its information from `upower`, `acpi`, |
| 5 | `acpitool` or from `apm`, to be as uniquely usable as possible. With `apm` as the |
| 6 | backend, some information might not be available, such as whether the battery is |
| 7 | currently charged or whether it is discharging. Charge is displayed with either |
| 8 | backends. |
| 9 | If you click on the widget, additional information is displayed. |
| 10 | |
| 11 | To use it, include it into your rc.lua by inserting this line: |
| 12 | |
| 13 | ```lua |
| 14 | local battery = require("obvious.battery") |
| 15 | ``` |
| 16 | |
| 17 | into the top of your rc.lua. Then add the widget to your wibox. It's called |
| 18 | |
| 19 | ```lua |
| 20 | battery() |
| 21 | ``` |
| 22 | |
| 23 | If you want to use the data gathered by this widget to create your own, use the |
| 24 | function `battery.get_data()`. It returns nil on failure and it returns |
| 25 | a table on success. If you have multiple batteries, only information for the |
| 26 | first is returned. The table has the following fields: |
| 27 | |
| 28 | * `status`: a string which describes the batteries' state as one element of the |
| 29 | set `["charged", "full", "discharging", "charging"]` (most likely, some |
| 30 | acpi implementations might output different values) |
| 31 | * `charge`: a number representing the current battery charge as a number between |
| 32 | 0 and 100 |
| 33 | * `time`: the time left to full charge or complete discharge, in minutes |
| 34 | |
| 35 | To set your preferred backend: |
| 36 | |
| 37 | local battery = require("obvious.battery") |
| 38 | battery.preferred_backend = 'apm' |
| 39 | battery() |