Skip to main content

Battery

What

caution

The segment is not supported and automatically disabled on Windows when WSL 1 is detected. Works fine with WSL 2.

Battery displays the remaining power percentage for your battery.

Sample Configuration

{
"type": "battery",
"style": "powerline",
"powerline_symbol": "",
"foreground": "#193549",
"background": "#ffeb3b",
"background_templates": [
"{{if eq \"Charging\" .State.String}}#40c4ff{{end}}",
"{{if eq \"Discharging\" .State.String}}#ff5722{{end}}",
"{{if eq \"Full\" .State.String}}#4caf50{{end}}"
],
"template": " {{ if not .Error }}{{ .Icon }}{{ .Percentage }}{{ end }} ",
"properties": {
"discharging_icon": " ",
"charging_icon": " ",
"charged_icon": " "
}
}

Properties

NameTypeDefaultDescription
display_errorbooleanfalseshow the error context when failing to retrieve the battery information
charging_iconstringicon to display when charging
discharging_iconstringicon to display when discharging
charged_iconstringicon to display when fully charged
not_charging_iconstringicon to display when fully charged

Template (info)

default template
{{ if not .Error }}{{ .Icon }}{{ .Percentage }}{{ end }}{{ .Error }}

Properties

NameTypeDescription
.Statestructthe battery state, has a .String function
.Currentfloat64Current (momentary) charge rate (in mW).
.Fullfloat64Last known full capacity (in mWh)
.Designfloat64Reported design capacity (in mWh)
.ChargeRatefloat64Current (momentary) charge rate (in mW). It is always non-negative, consult .State field to check whether it means charging or discharging (on some systems this might be always 0 if the battery doesn't support it)
.Voltagefloat64Current voltage (in V)
.DesignVoltagefloat64Design voltage (in V). Some systems (e.g. macOS) do not provide a separate value for this. In such cases, or if getting this fails, but getting Voltage succeeds, this field will have the same value as Voltage, for convenience
.Percentagefloat64the current battery percentage
.Errorstringthe error in case fetching the battery information failed
.Iconstringthe icon based on the battery state