Saltar al contenido principal

Batería

Traducción Beta No Oficial

Esta página fue traducida por PageTurner AI (beta). No está respaldada oficialmente por el proyecto. ¿Encontraste un error? Reportar problema →

Qué hace

precaución

Este segmento no es compatible y se desactiva automáticamente en Windows cuando se detecta WSL 1. Funciona correctamente con WSL 2.

Batería muestra el porcentaje de energía restante en tu batería.

Configuración de ejemplo

{
"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 }} ",
"options": {
"discharging_icon": " ",
"charging_icon": " ",
"charged_icon": " "
}
}

Opciones

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

Plantilla (info)

plantilla predeterminada
 {{ if not .Error }}{{ .Icon }}{{ .Percentage }}{{ end }}{{ .Error }}

Propiedades

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