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