battery
Battery level, charging state, and a dropdown with the batteries of peripherals UPower reports (wireless mice, keyboards, controllers, pens) and power-profile controls. Low and critical battery levels send critical notifications whether or not the module is placed.
The battery is UPower's sample of the kernel's /sys/class/power_supply. Its warning levels are UPower's too, and upower.conf sets them (PercentageLow, PercentageCritical and PercentageAction, 10, 5 and 2 by default); no key here changes when a battery warns. The dropdown's gauge and percentage are painted by those levels as well: yellow at PercentageLow, red at PercentageCritical or PercentageAction, with no percentage of their own.
Add it to your layout with battery:
bar:
layout:
- monitor: "*"
right: [battery]General
| Field | Type | Default | Description |
|---|---|---|---|
level-icons | array of string | [...] | Icons for battery levels from empty to full. |
charging-icon | string | "ld-battery-animated-symbolic" | Icon shown when battery is charging. |
alert-icon | string | "ld-battery-animated-symbolic" | Icon shown when battery is not present or in an error state. |
border-show | bool | false | Display border around button. |
icon-show | bool | true | Display module icon. |
tooltip | bool | true | Show the module's state in a tooltip on hover. |
label | LabelMode | "hover" | When the label beside the icon shows the charge percentage; hover grows it out while the pointer is on the module. |
format | string | "{{ percent }}%" | Format string for the label. |
label-max-length | u32 | 0 | Max label characters before truncation with ellipsis. Set to 0 to disable. |
notify-low | bool | true | Send a critical notification when the battery, or a peripheral UPower reports such as a wireless mouse, enters the low or critical warning level. |
notify-charged-at | Percentage | 0 | Notify once when the charging battery reaches this percentage. Set to 0 to disable. |
app-nap | map of NapLevel | {} | How hard each app naps while the user cannot see it, by app ID. |
More about level-icons
The percentage is divided evenly among icons. With 5 icons: 0-20% uses icons[0], 21-40% uses icons[1], etc.
Every battery icon is also put in the state of the charge (empty, low, medium, full), charging or alert; the default is one animated icon that declares them, and an icon without states ignores them.
More about format
Placeholders
{{ percent }}- Battery level (0-100)
Examples
"{{ percent }}%"- "45%"
More about notify-low
The levels are UPower's, which upower.conf sets: PercentageLow, PercentageCritical and PercentageAction, 10, 5 and 2 by default, on battery. Each level notifies once; plugging in and unplugging again re-arms them.
The Low Power offer is not one of those levels: it comes at 20% on battery, as iOS offers it, before PercentageLow warns, so there is still charge to save by accepting it. It has a button that turns power-saver on, once until the next unplug, and never while power-saver is already on.
More about app-nap
An app not listed naps at default. Freezing and the efficiency cores are never the default: a frozen app's downloads and sockets stop, and a hidden build is real work.
Example: {"org.mozilla.firefox": "never", "com.slack.Slack": "frozen"}
Colors
| Field | Type | Default | Description |
|---|---|---|---|
border-color | ColorValue | "yellow" | Border color token. |
icon-color | ColorValue | "auto" | Icon foreground color. Auto selects based on variant for contrast. |
icon-bg-color | ColorValue | "yellow" | Icon container background color token. |
label-color | ColorValue | "fg-default" | Label text color token. |
button-bg-color | ColorValue | "bg-surface-elevated" | Button background color token. |
Click actions
| Field | Type | Default | Description |
|---|---|---|---|
left-click | ClickAction | "dropdown:battery" | Action on left click. |
right-click | ClickAction | "" | Action on right click. |
middle-click | ClickAction | "" | Action on middle click. |
scroll-up | ClickAction | "" | Action on scroll up. |
scroll-down | ClickAction | "" | Action on scroll down. |
Default configuration
modules:
battery:
level-icons:
- ld-battery-animated-symbolic
charging-icon: ld-battery-animated-symbolic
alert-icon: ld-battery-animated-symbolic
border-show: false
border-color: yellow
icon-show: true
tooltip: true
icon-color: auto
icon-bg-color: yellow
label: hover
label-color: fg-default
format: '{{ percent }}%'
label-max-length: 0
button-bg-color: bg-surface-elevated
left-click: dropdown:battery
right-click: ""
middle-click: ""
scroll-up: ""
scroll-down: ""
notify-low: true
notify-charged-at: 0
app-nap: {}