Skip to content
Caleb Bassi edited this page Dec 28, 2018 · 30 revisions

Battery

The battery module displays the current capacity and state (eg. charging) of your battery.

Config

Addressed by battery

option typeof default description
bat string The battery to monitor, as in /sys/class/power_supply/ instead of auto detect.
adapter string The adapter to monitor, as in /sys/class/power_supply/ instead of auto detect.
interval integer 60 The interval in which the information gets polled.
states array A number of battery states which get activated on certain capacity levels.
See States
format string {capacity}% The format, how the time should be displayed.
format-icons array Based on the current capacity, the corresponding icon gets selected.
The order is low to high.
max-length integer The maximum length in character the module should display.
on-click string Command to execute when clicked on the module.
on-click-right string Command to execute when you right clicked on the module.
on-scroll-up string Command to execute when scrolling up on the module.
on-scroll-down string Command to execute when scrolling down on the module.

Format replacements:

string replacement
{capacity} Capacity in percentage
{icon} Icon, as defined in format-icons.

Custom Formats:

The battery module allows to define custom formats based on up to two factors. The best fitting format will be selected.

format description
format-<state> With states, a custom format can be set depending on the capacity of your battery.
format-<status> With the status, a custom format can be set depending on the status in /sys/class/power_supply/<bat>/status (in lowercase).
format-<status>-<state> You can also set a custom format depending on both vaules.

States:

  • Every entry (state) consits of a <name> (typeof: string) and a <value> (typeof: integer).
    • The state can be adressed as a CSS class in the style.css. The name of the CSS class is the <name> of the state. Each class gets activated when the current capacity is equal or below the configured <value>.
    • Also each state can have its own format. Those con be configured via format-<name>. Or if you want to differntiate a bit more even as format-<status>-<state>. For more information see custom formats.

Example:

"battery": {
    "bat": "BAT2",
    "interval": 60,
    "states": {
        "warning": 30,
        "critical": 15
    },
    "format": "{capacity}% {icon}",
    "format-icons": ["", "", "", "", ""],
    "max-length": 25
}

Style

  • #battery
  • #battery.<status>
    • <status> is the value of /sys/class/power_supply/<bat>/status in lowercase.
  • #battery.<state>
    • <state> can be defined in the config. For more information see states
  • #battery.<status>.<state>
    • Combination of both <status> and <state>.
Clone this wiki locally