feat(battery): decouple not charging from discharging

resolves #2237
This commit is contained in:
Jan De Dobbeleer 2022-05-10 07:25:05 +02:00 committed by Jan De Dobbeleer
parent 0daeb9829d
commit e392ab667d
3 changed files with 18 additions and 7 deletions

View file

@ -38,9 +38,10 @@ Battery displays the remaining power percentage for your battery.
## Properties
- display_error: `boolean` - show the error context when failing to retrieve the battery information - defaults to `false`
- charging_icon: `string` - icon to display on the left when charging - defaults to empty
- discharging_icon: `string` - icon to display on the left when discharging - defaults to empty
- charged_icon: `string` - icon to display on the left when fully charged - defaults to empty
- charging_icon: `string` - icon to display when charging - defaults to empty
- discharging_icon: `string` - icon to display when discharging - defaults to empty
- charged_icon: `string` - icon to display when fully charged - defaults to empty
- not_charging_icon: `string` - icon to display when fully charged - defaults to empty
## Template ([info][templates])

View file

@ -23,6 +23,8 @@ const (
DischargingIcon properties.Property = "discharging_icon"
// ChargedIcon to display when fully charged
ChargedIcon properties.Property = "charged_icon"
// NotChargingIcon to display when on AC power
NotChargingIcon properties.Property = "not_charging_icon"
)
func (b *Battery) Template() string {
@ -48,8 +50,10 @@ func (b *Battery) Enabled() bool {
}
switch b.BatteryInfo.State {
case battery.Discharging, battery.NotCharging:
case battery.Discharging:
b.Icon = b.props.GetString(DischargingIcon, "")
case battery.NotCharging:
b.Icon = b.props.GetString(NotChargingIcon, "")
case battery.Charging:
b.Icon = b.props.GetString(ChargingIcon, "")
case battery.Full:

View file

@ -371,19 +371,25 @@
"charging_icon": {
"type": "string",
"title": "Charging Icon",
"description": "Text/icon to display on the left when charging",
"description": "Text/icon to display when charging",
"default": ""
},
"discharging_icon": {
"type": "string",
"title": "discharging Dcon",
"description": "Text/icon to display on the left when discharging",
"description": "Text/icon to display when discharging",
"default": ""
},
"charged_icon": {
"type": "string",
"title": "Charged Icon",
"description": "Text/icon to display on the left when fully charged",
"description": "Text/icon to display when fully charged",
"default": ""
},
"not_charging_icon": {
"type": "string",
"title": "Not Charging Icon",
"description": "Text/icon to display when on AC power",
"default": ""
}
}