refactor(battery): remove legacy properties

This commit is contained in:
Jan De Dobbeleer 2021-11-25 13:55:03 +01:00 committed by Jan De Dobbeleer
parent fa38b516b1
commit b94e96dd15
20 changed files with 340 additions and 324 deletions

View file

@ -128,14 +128,9 @@ _Color override_ ([Battery segment][battery]):
"foreground": "p:white",
"background": "p:black",
"properties": {
"battery_icon": "<#ffa500> [II ]- </>", // icon should always be orange
"discharging_icon": "- ",
"discharging_icon": "<#ffa500>-</> ",
"charging_icon": "+ ",
"charged_icon": "* ",
"color_background": true,
"charged_color": "#4caf50", //
"charging_color": "#40c4ff", // battery should use specific colors for status
"discharging_color": "#ff5722", //
}
},
```

View file

@ -17,18 +17,17 @@ Battery displays the remaining power percentage for your battery.
"powerline_symbol": "\uE0B0",
"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}}"
],
"properties": {
"battery_icon": "",
"discharging_icon": "\uE231 ",
"charging_icon": "\uE234 ",
"charged_icon": "\uE22F ",
"color_background": true,
"charged_color": "#4caf50",
"charging_color": "#40c4ff",
"discharging_color": "#ff5722",
"postfix": "\uF295 ",
"display_charging": true,
"display_charged": true
"template": "{{ if not .Error }}{{.Icon}}{{.Percentage}}{{ end }}"
}
}
```
@ -41,16 +40,19 @@ properties below - defaults to `{{.Icon}}{{ if not .Error }}{{.Percentage}}{{ en
- 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
- color_background: `boolean` - color the background or foreground for properties below - defaults to `false`
- charged_color: `string` [color][colors] - color to use when fully charged - defaults to segment color
- charging_color: `string` [color][colors] - color to use when charging - defaults to segment color
- discharging_color: `string` [color][colors] - color to use when discharging - defaults to segment color
- display_charging: `bool` - displays the battery status while charging (Charging)
- display_charged: `bool` - displays the battery status when charged (Full)
## Template Properties
- `.Battery`: `struct` - the [battery][battery] object, you can use any property it has e.g. `.Battery.State`
- `.State`: `struct` - the battery state, has a `.String` function
- `.Current`: `float64` - Current (momentary) charge rate (in mW).
- `.Full`: `float64` - Last known full capacity (in mWh)
- `.Design`: `float64` - Reported design capacity (in mWh)
- `.ChargeRate`: `float64` - Current (momentary) charge rate (in mW). It is always non-negative, consult .State
field to check whether it means charging or discharging
- `.Voltage`: `float64` - Current voltage (in V)
- `.DesignVoltage`: `float64` - Design 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
- `.Percentage`: `float64` - the current battery percentage
- `.Error`: `string` - the error in case fetching the battery information failed
- `.Icon`: `string` - the icon based on the battery state

View file

@ -23,16 +23,6 @@ const (
DischargingIcon Property = "discharging_icon"
// ChargedIcon to display when fully charged
ChargedIcon Property = "charged_icon"
// ChargedColor to display when fully charged
ChargedColor Property = "charged_color"
// ChargingColor to display when charging
ChargingColor Property = "charging_color"
// DischargingColor to display when discharging
DischargingColor Property = "discharging_color"
// DisplayCharging Hide the battery icon while it's charging
DisplayCharging Property = "display_charging"
// DisplayCharged Hide the battery icon when it's charged
DisplayCharged Property = "display_charged"
)
func (b *batt) enabled() bool {
@ -52,38 +42,24 @@ func (b *batt) enabled() bool {
b.Battery.Full += bt.Full
b.Battery.State = b.mapMostLogicalState(b.Battery.State, bt.State)
}
displayCharged := b.props.getBool(DisplayCharged, true)
if !displayCharged && (b.Battery.State == battery.Full) {
return false
}
displayCharging := b.props.getBool(DisplayCharging, true)
if !displayCharging && (b.Battery.State == battery.Charging) {
return false
}
batteryPercentage := b.Battery.Current / b.Battery.Full * 100
b.Percentage = int(math.Min(100, batteryPercentage))
var colorPorperty Property
if !b.shouldDisplay() {
return false
}
switch b.Battery.State {
case battery.Discharging, battery.NotCharging:
colorPorperty = DischargingColor
b.Icon = b.props.getString(DischargingIcon, "")
case battery.Charging:
colorPorperty = ChargingColor
b.Icon = b.props.getString(ChargingIcon, "")
case battery.Full:
colorPorperty = ChargedColor
b.Icon = b.props.getString(ChargedIcon, "")
case battery.Empty, battery.Unknown:
return true
}
colorBackground := b.props.getBool(ColorBackground, false)
if colorBackground {
b.props.background = b.props.getColor(colorPorperty, b.props.background)
} else {
b.props.foreground = b.props.getColor(colorPorperty, b.props.foreground)
}
b.colorSegment()
return true
}

View file

@ -1,7 +1,6 @@
package main
import (
"errors"
"testing"
"github.com/distatus/battery"
@ -14,137 +13,6 @@ const (
chargedColor = "#248644"
)
func TestBatterySegmentSingle(t *testing.T) {
cases := []struct {
Case string
Batteries []*battery.Battery
ExpectedString string
ExpectedEnabled bool
ExpectedColor string
ColorBackground bool
DisplayError bool
Error error
DisableCharging bool
DisableCharged bool
}{
{Case: "80% charging", Batteries: []*battery.Battery{{Full: 100, State: battery.Charging, Current: 80}}, ExpectedString: "charging 80", ExpectedEnabled: true},
{Case: "battery full", Batteries: []*battery.Battery{{Full: 100, State: battery.Full, Current: 100}}, ExpectedString: "charged 100", ExpectedEnabled: true},
{Case: "70% discharging", Batteries: []*battery.Battery{{Full: 100, State: battery.Discharging, Current: 70}}, ExpectedString: "going down 70", ExpectedEnabled: true},
{
Case: "discharging background color",
Batteries: []*battery.Battery{{Full: 100, State: battery.Discharging, Current: 70}},
ExpectedString: "going down 70",
ExpectedEnabled: true,
ColorBackground: true,
ExpectedColor: dischargingColor,
},
{
Case: "charging background color",
Batteries: []*battery.Battery{{Full: 100, State: battery.Charging, Current: 70}},
ExpectedString: "charging 70",
ExpectedEnabled: true,
ColorBackground: true,
ExpectedColor: chargingColor,
},
{
Case: "charged background color",
Batteries: []*battery.Battery{{Full: 100, State: battery.Full, Current: 70}},
ExpectedString: "charged 70",
ExpectedEnabled: true,
ColorBackground: true,
ExpectedColor: chargedColor,
},
{
Case: "discharging foreground color",
Batteries: []*battery.Battery{{Full: 100, State: battery.Discharging, Current: 70}},
ExpectedString: "going down 70",
ExpectedEnabled: true,
ExpectedColor: dischargingColor,
},
{
Case: "charging foreground color",
Batteries: []*battery.Battery{{Full: 100, State: battery.Charging, Current: 70}},
ExpectedString: "charging 70",
ExpectedEnabled: true,
ExpectedColor: chargingColor,
},
{
Case: "charged foreground color",
Batteries: []*battery.Battery{{Full: 100, State: battery.Full, Current: 70}},
ExpectedString: "charged 70",
ExpectedEnabled: true,
ExpectedColor: chargedColor,
},
{Case: "battery error", DisplayError: true, Error: errors.New("oh snap"), ExpectedString: "oh snap", ExpectedEnabled: true},
{Case: "battery error disabled", Error: errors.New("oh snap")},
{Case: "no batteries", DisplayError: true, Error: &noBatteryError{}},
{Case: "no batteries without error"},
{Case: "display charging disabled: charging", Batteries: []*battery.Battery{{Full: 100, State: battery.Charging}}, DisableCharging: true},
{Case: "display charged disabled: charged", Batteries: []*battery.Battery{{Full: 100, State: battery.Full}}, DisableCharged: true},
{
Case: "display charging disabled/display charged enabled: charging",
Batteries: []*battery.Battery{{Full: 100, State: battery.Charging}},
DisableCharging: true,
DisableCharged: false},
{
Case: "display charged disabled/display charging enabled: charged",
Batteries: []*battery.Battery{{Full: 100, State: battery.Full}},
DisableCharged: true,
DisableCharging: false},
{
Case: "display charging disabled: discharging",
Batteries: []*battery.Battery{{Full: 100, State: battery.Discharging, Current: 70}},
ExpectedString: "going down 70",
ExpectedEnabled: true,
DisableCharging: true,
},
}
for _, tc := range cases {
env := &MockedEnvironment{}
props := &properties{
background: "#111111",
foreground: "#ffffff",
values: map[Property]interface{}{
ChargingIcon: "charging ",
ChargedIcon: "charged ",
DischargingIcon: "going down ",
DischargingColor: dischargingColor,
ChargedColor: chargedColor,
ChargingColor: chargingColor,
ColorBackground: tc.ColorBackground,
DisplayError: tc.DisplayError,
},
}
// default values
if tc.DisableCharging {
props.values[DisplayCharging] = false
}
if tc.DisableCharged {
props.values[DisplayCharged] = false
}
env.On("getBatteryInfo", nil).Return(tc.Batteries, tc.Error)
b := &batt{
props: props,
env: env,
}
enabled := b.enabled()
assert.Equal(t, tc.ExpectedEnabled, enabled, tc.Case)
if !enabled {
continue
}
assert.Equal(t, tc.ExpectedString, b.string(), tc.Case)
if len(tc.ExpectedColor) == 0 {
continue
}
actualColor := b.props.foreground
if tc.ColorBackground {
actualColor = b.props.background
}
assert.Equal(t, tc.ExpectedColor, actualColor, tc.Case)
}
}
func TestGetBatteryColors(t *testing.T) {
cases := []struct {
Case string

View file

@ -4,8 +4,29 @@ import (
"bytes"
"fmt"
"strings"
"github.com/distatus/battery"
)
// Properties
func (p *properties) getOneOfBool(property, legacyProperty Property) bool {
_, found := p.values[legacyProperty]
if found {
return p.getBool(legacyProperty, false)
}
return p.getBool(property, false)
}
func (p *properties) hasOneOf(properties ...Property) bool {
for _, property := range properties {
if _, found := p.values[property]; found {
return true
}
}
return false
}
// GIT Segement
const (
@ -45,14 +66,6 @@ const (
StatusSeparatorIcon Property = "status_separator_icon"
)
func (g *git) getBool(property, legacyProperty Property) bool {
_, found := g.props.values[legacyProperty]
if found {
return g.props.getBool(legacyProperty, false)
}
return g.props.getBool(property, false)
}
func (g *git) deprecatedString(statusColorsEnabled bool) string {
if statusColorsEnabled {
g.SetStatusColor()
@ -166,3 +179,56 @@ func (e *exit) deprecatedString() string {
}
return fmt.Sprintf("%s%s", errorIcon, e.Text)
}
// Battery segment
const (
// ChargedColor to display when fully charged
ChargedColor Property = "charged_color"
// ChargingColor to display when charging
ChargingColor Property = "charging_color"
// DischargingColor to display when discharging
DischargingColor Property = "discharging_color"
// DisplayCharging Hide the battery icon while it's charging
DisplayCharging Property = "display_charging"
// DisplayCharged Hide the battery icon when it's charged
DisplayCharged Property = "display_charged"
)
func (b *batt) colorSegment() {
if !b.props.hasOneOf(ChargedColor, ChargingColor, DischargingColor) {
return
}
var colorProperty Property
switch b.Battery.State {
case battery.Discharging, battery.NotCharging:
colorProperty = DischargingColor
case battery.Charging:
colorProperty = ChargingColor
case battery.Full:
colorProperty = ChargedColor
case battery.Empty, battery.Unknown:
return
}
colorBackground := b.props.getBool(ColorBackground, false)
if colorBackground {
b.props.background = b.props.getColor(colorProperty, b.props.background)
} else {
b.props.foreground = b.props.getColor(colorProperty, b.props.foreground)
}
}
func (b *batt) shouldDisplay() bool {
if !b.props.hasOneOf(DisplayCharged, DisplayCharging) {
return true
}
displayCharged := b.props.getBool(DisplayCharged, true)
if !displayCharged && (b.Battery.State == battery.Full) {
return false
}
displayCharging := b.props.getBool(DisplayCharging, true)
if !displayCharging && (b.Battery.State == battery.Charging) {
return false
}
return true
}

View file

@ -1,8 +1,10 @@
package main
import (
"errors"
"testing"
"github.com/distatus/battery"
"github.com/stretchr/testify/assert"
)
@ -301,3 +303,136 @@ func TestExitWriterDeprecatedString(t *testing.T) {
assert.Equal(t, tc.Expected, e.string())
}
}
// Battery Segment
func TestBatterySegmentSingle(t *testing.T) {
cases := []struct {
Case string
Batteries []*battery.Battery
ExpectedString string
ExpectedEnabled bool
ExpectedColor string
ColorBackground bool
DisplayError bool
Error error
DisableCharging bool
DisableCharged bool
}{
{Case: "80% charging", Batteries: []*battery.Battery{{Full: 100, State: battery.Charging, Current: 80}}, ExpectedString: "charging 80", ExpectedEnabled: true},
{Case: "battery full", Batteries: []*battery.Battery{{Full: 100, State: battery.Full, Current: 100}}, ExpectedString: "charged 100", ExpectedEnabled: true},
{Case: "70% discharging", Batteries: []*battery.Battery{{Full: 100, State: battery.Discharging, Current: 70}}, ExpectedString: "going down 70", ExpectedEnabled: true},
{
Case: "discharging background color",
Batteries: []*battery.Battery{{Full: 100, State: battery.Discharging, Current: 70}},
ExpectedString: "going down 70",
ExpectedEnabled: true,
ColorBackground: true,
ExpectedColor: dischargingColor,
},
{
Case: "charging background color",
Batteries: []*battery.Battery{{Full: 100, State: battery.Charging, Current: 70}},
ExpectedString: "charging 70",
ExpectedEnabled: true,
ColorBackground: true,
ExpectedColor: chargingColor,
},
{
Case: "charged background color",
Batteries: []*battery.Battery{{Full: 100, State: battery.Full, Current: 70}},
ExpectedString: "charged 70",
ExpectedEnabled: true,
ColorBackground: true,
ExpectedColor: chargedColor,
},
{
Case: "discharging foreground color",
Batteries: []*battery.Battery{{Full: 100, State: battery.Discharging, Current: 70}},
ExpectedString: "going down 70",
ExpectedEnabled: true,
ExpectedColor: dischargingColor,
},
{
Case: "charging foreground color",
Batteries: []*battery.Battery{{Full: 100, State: battery.Charging, Current: 70}},
ExpectedString: "charging 70",
ExpectedEnabled: true,
ExpectedColor: chargingColor,
},
{
Case: "charged foreground color",
Batteries: []*battery.Battery{{Full: 100, State: battery.Full, Current: 70}},
ExpectedString: "charged 70",
ExpectedEnabled: true,
ExpectedColor: chargedColor,
},
{Case: "battery error", DisplayError: true, Error: errors.New("oh snap"), ExpectedString: "oh snap", ExpectedEnabled: true},
{Case: "battery error disabled", Error: errors.New("oh snap")},
{Case: "no batteries", DisplayError: true, Error: &noBatteryError{}},
{Case: "no batteries without error"},
{Case: "display charging disabled: charging", Batteries: []*battery.Battery{{Full: 100, State: battery.Charging}}, DisableCharging: true},
{Case: "display charged disabled: charged", Batteries: []*battery.Battery{{Full: 100, State: battery.Full}}, DisableCharged: true},
{
Case: "display charging disabled/display charged enabled: charging",
Batteries: []*battery.Battery{{Full: 100, State: battery.Charging}},
DisableCharging: true,
DisableCharged: false},
{
Case: "display charged disabled/display charging enabled: charged",
Batteries: []*battery.Battery{{Full: 100, State: battery.Full}},
DisableCharged: true,
DisableCharging: false},
{
Case: "display charging disabled: discharging",
Batteries: []*battery.Battery{{Full: 100, State: battery.Discharging, Current: 70}},
ExpectedString: "going down 70",
ExpectedEnabled: true,
DisableCharging: true,
},
}
for _, tc := range cases {
env := &MockedEnvironment{}
props := &properties{
background: "#111111",
foreground: "#ffffff",
values: map[Property]interface{}{
ChargingIcon: "charging ",
ChargedIcon: "charged ",
DischargingIcon: "going down ",
DischargingColor: dischargingColor,
ChargedColor: chargedColor,
ChargingColor: chargingColor,
ColorBackground: tc.ColorBackground,
DisplayError: tc.DisplayError,
},
}
// default values
if tc.DisableCharging {
props.values[DisplayCharging] = false
}
if tc.DisableCharged {
props.values[DisplayCharged] = false
}
env.On("getBatteryInfo", nil).Return(tc.Batteries, tc.Error)
b := &batt{
props: props,
env: env,
}
enabled := b.enabled()
assert.Equal(t, tc.ExpectedEnabled, enabled, tc.Case)
if !enabled {
continue
}
assert.Equal(t, tc.ExpectedString, b.string(), tc.Case)
if len(tc.ExpectedColor) == 0 {
continue
}
actualColor := b.props.foreground
if tc.ColorBackground {
actualColor = b.props.background
}
assert.Equal(t, tc.ExpectedColor, actualColor, tc.Case)
}
}

View file

@ -185,20 +185,20 @@ func (g *git) shouldIgnoreRootRepository(rootDir string) bool {
func (g *git) string() string {
statusColorsEnabled := g.props.getBool(StatusColorsEnabled, false)
displayStatus := g.getBool(FetchStatus, DisplayStatus)
displayStatus := g.props.getOneOfBool(FetchStatus, DisplayStatus)
if !displayStatus {
g.HEAD = g.getPrettyHEADName()
}
if displayStatus || statusColorsEnabled {
g.setGitStatus()
}
if g.Upstream != "" && g.getBool(FetchUpstreamIcon, DisplayUpstreamIcon) {
if g.Upstream != "" && g.props.getOneOfBool(FetchUpstreamIcon, DisplayUpstreamIcon) {
g.UpstreamIcon = g.getUpstreamIcon()
}
if g.getBool(FetchStashCount, DisplayStashCount) {
if g.props.getOneOfBool(FetchStashCount, DisplayStashCount) {
g.StashCount = g.getStashContext()
}
if g.getBool(FetchWorktreeCount, DisplayWorktreeCount) {
if g.props.getOneOfBool(FetchWorktreeCount, DisplayWorktreeCount) {
g.WorktreeCount = g.getWorktreeContext()
}
// use template if available

View file

@ -38,8 +38,8 @@
{
"type": "session",
"style": "diamond",
"foreground": "palette:white",
"background": "palette:session",
"foreground": "p:white",
"background": "p:session",
"leading_diamond": "",
"trailing_diamond": "\uE0B0",
"properties": {
@ -51,8 +51,8 @@
"type": "path",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "palette:white",
"background": "palette:path",
"foreground": "p:white",
"background": "p:path",
"properties": {
"prefix": "  ",
"home_icon": "~",
@ -64,13 +64,13 @@
"type": "git",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "palette:git-foreground",
"background": "palette:git",
"foreground": "p:git-foreground",
"background": "p:git",
"background_templates": [
"{{ if or (.Working.Changed) (.Staging.Changed) }}palette:git-modified{{ end }}",
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}palette:git-diverged{{ end }}",
"{{ if gt .Ahead 0 }}palette:git-ahead{{ end }}",
"{{ if gt .Behind 0 }}palette:git-behind{{ end }}"
"{{ if or (.Working.Changed) (.Staging.Changed) }}p:git-modified{{ end }}",
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}p:git-diverged{{ end }}",
"{{ if gt .Ahead 0 }}p:git-ahead{{ end }}",
"{{ if gt .Behind 0 }}p:git-behind{{ end }}"
],
"leading_diamond": "",
"trailing_diamond": "",
@ -86,8 +86,8 @@
"type": "node",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "palette:white",
"background": "palette:node",
"foreground": "p:white",
"background": "p:node",
"properties": {
"prefix": " \uF898 ",
"display_version": true
@ -97,8 +97,8 @@
"type": "go",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "palette:black",
"background": "palette:go",
"foreground": "p:black",
"background": "p:go",
"properties": {
"prefix": " \uE626 ",
"display_version": true
@ -108,8 +108,8 @@
"type": "julia",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "palette:black",
"background": "palette:julia",
"foreground": "p:black",
"background": "p:julia",
"properties": {
"prefix": " \uE624 ",
"display_version": true
@ -119,8 +119,8 @@
"type": "python",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "palette:black",
"background": "palette:python",
"foreground": "p:black",
"background": "p:python",
"properties": {
"prefix": " \uE235 ",
"display_version": true,
@ -132,8 +132,8 @@
"type": "ruby",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "palette:white",
"background": "palette:ruby",
"foreground": "p:white",
"background": "p:ruby",
"properties": {
"prefix": " \uE791 ",
"display_version": true,
@ -144,8 +144,8 @@
"type": "azfunc",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "palette:white",
"background": "palette:azfunc",
"foreground": "p:white",
"background": "p:azfunc",
"properties": {
"prefix": " \uf0e7",
"display_version": false,
@ -156,10 +156,10 @@
"type": "aws",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "palette:white",
"foreground": "p:white",
"background_templates": [
"{{if contains \"default\" .Profile}}palette:aws-default{{end}}",
"{{if contains \"jan\" .Profile}}palette:aws-jan{{end}}"
"{{if contains \"default\" .Profile}}p:aws-default{{end}}",
"{{if contains \"jan\" .Profile}}p:aws-jan{{end}}"
],
"properties": {
"prefix": " \uE7AD ",
@ -170,8 +170,8 @@
"type": "root",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "palette:black",
"background": "palette:root",
"foreground": "p:black",
"background": "p:root",
"properties": {
"root_icon": ""
}
@ -179,8 +179,8 @@
{
"type": "executiontime",
"style": "plain",
"foreground": "palette:white",
"background": "palette:executiontime",
"foreground": "p:white",
"background": "p:executiontime",
"leading_diamond": "",
"trailing_diamond": "",
"properties": {
@ -192,10 +192,10 @@
{
"type": "exit",
"style": "diamond",
"foreground": "palette:white",
"background": "palette:exit",
"foreground": "p:white",
"background": "p:exit",
"background_templates": [
"{{ if gt .Code 0 }}palette:exit-red{{ end }}"
"{{ if gt .Code 0 }}p:exit-red{{ end }}"
],
"leading_diamond": "",
"trailing_diamond": "\uE0B4",
@ -213,8 +213,8 @@
{
"type": "shell",
"style": "plain",
"foreground": "palette:white",
"background": "palette:shell",
"foreground": "p:white",
"background": "p:shell",
"properties": {
"prefix": "<#0077c2,transparent>\uE0B6</>  ",
"postfix": " <transparent,#0077c2>\uE0B2</>"
@ -225,8 +225,8 @@
"style": "powerline",
"powerline_symbol": "\uE0B2",
"invert_powerline": true,
"foreground": "palette:black",
"background": "palette:ytm",
"foreground": "p:black",
"background": "p:ytm",
"properties": {
"prefix": " \uF167 ",
"paused_icon": " ",
@ -238,17 +238,17 @@
"style": "powerline",
"invert_powerline": true,
"powerline_symbol": "\uE0B2",
"foreground": "palette:white",
"background": "palette:battery",
"foreground": "p:white",
"background": "p:battery",
"background_templates": [
"{{if eq \"Charging\" .State.String}}p:battery-charging{{end}}",
"{{if eq \"Discharging\" .State.String}}p:battery-discharging{{end}}",
"{{if eq \"Full\" .State.String}}p:battery-charged{{end}}"
],
"properties": {
"battery_icon": "",
"discharging_icon": " ",
"charging_icon": " ",
"charged_icon": " ",
"color_background": true,
"charged_color": "palette:battery-charged",
"charging_color": "palette:battery-charging",
"discharging_color": "palette:battery-discharging",
"postfix": " "
}
},
@ -258,8 +258,8 @@
"invert_powerline": true,
"leading_diamond": "\uE0B2",
"trailing_diamond": "\uE0B4",
"background": "palette:time",
"foreground": "palette:black"
"background": "p:time",
"foreground": "p:black"
}
]
}

View file

@ -207,15 +207,15 @@
"powerline_symbol": "\uE0B2",
"foreground": "#ffffff",
"background": "#f36943",
"background_templates": [
"{{if eq \"Charging\" .State.String}}#40c4ff{{end}}",
"{{if eq \"Discharging\" .State.String}}#ff5722{{end}}",
"{{if eq \"Full\" .State.String}}#4caf50{{end}}"
],
"properties": {
"battery_icon": "",
"discharging_icon": " ",
"charging_icon": " ",
"charged_icon": " ",
"color_background": true,
"charged_color": "#4caf50",
"charging_color": "#40c4ff",
"discharging_color": "#ff5722",
"postfix": " "
}
},

View file

@ -266,15 +266,15 @@
"trailing_diamond": "",
"foreground": "#262626",
"background": "#f36943",
"background_templates": [
"{{if eq \"Charging\" .State.String}}#b8e994{{end}}",
"{{if eq \"Discharging\" .State.String}}#fff34e{{end}}",
"{{if eq \"Full\" .State.String}}#33DD2D{{end}}"
],
"properties": {
"battery_icon": "",
"discharging_icon": " ",
"charging_icon": "\uf1e6 ",
"charged_icon": "\uf58e ",
"color_background": true,
"charged_color": "#33DD2D",
"charging_color": "#b8e994",
"discharging_color": "#fff34e",
"postfix": " <#262626>\uE0B2</>"
}
},

View file

@ -182,14 +182,16 @@
{
"type": "battery",
"style": "plain",
"foreground": "#ffffff",
"foreground_templates": [
"{{if eq \"Charging\" .State.String}}#40c4ff{{end}}",
"{{if eq \"Discharging\" .State.String}}#FFFB38{{end}}",
"{{if eq \"Full\" .State.String}}#33DD2D{{end}}"
],
"properties": {
"discharging_icon": " ",
"charging_icon": "\uf1e6 ",
"charged_icon": "\uf58e ",
"color_foreground": true,
"charged_color": "#33DD2D",
"charging_color": "#40c4ff",
"discharging_color": "#FFFB38",
"prefix": "<#ffffff>[</>",
"postfix": "%<#ffffff>]─</>"
}

View file

@ -30,12 +30,12 @@
"powerline_symbol": "\uE0B0",
"foreground": "#193549",
"background": "#a2beef",
"background_templates": [
"{{if eq \"Charging\" .State.String}}#00D100{{end}}",
"{{if eq \"Discharging\" .State.String}}#FFCD58{{end}}",
"{{if eq \"Full\" .State.String}}#0476d0{{end}}"
],
"properties": {
"battery_icon": "\f583",
"color_background": true,
"charged_color": "#0476d0",
"charging_color": "#00D100",
"discharging_color": "#FFCD58",
"postfix": "\uF295 \uf583 "
}
},

View file

@ -130,18 +130,17 @@
"leading_diamond": " \uE0B6",
"foreground": "#9B6BDF",
"background": "#29315A",
"foreground_templates": [
"{{if eq \"Charging\" .State.String}}#40c4ff{{end}}",
"{{if eq \"Discharging\" .State.String}}#ff5722{{end}}",
"{{if eq \"Full\" .State.String}}#4caf50{{end}}"
],
"properties": {
"battery_icon": "",
"discharging_icon": "\u21E3 ",
"charging_icon": "\u21E1 ",
"charged_icon": "\u0095 ",
"color_background": false,
"charged_color": "#4caf50",
"charging_color": "#40c4ff",
"discharging_color": "#ff5722",
"prefix": "",
"postfix": "",
"display_charging": true
"postfix": ""
}
}
]

View file

@ -117,18 +117,17 @@
"leading_diamond": " \uE0B6",
"foreground": "#9B6BDF",
"background": "#424242",
"foreground_templates": [
"{{if eq \"Charging\" .State.String}}#40c4ff{{end}}",
"{{if eq \"Discharging\" .State.String}}#ff5722{{end}}",
"{{if eq \"Full\" .State.String}}#4caf50{{end}}"
],
"properties": {
"battery_icon": "",
"discharging_icon": "\u21E3 ",
"charging_icon": "\u21E1 ",
"charged_icon": "\u25CF ",
"color_background": false,
"charged_color": "#4caf50",
"charging_color": "#40c4ff",
"discharging_color": "#ff5722",
"prefix": "",
"postfix": "",
"display_charging": true
"postfix": ""
}
}
]

View file

@ -76,18 +76,17 @@
"type": "battery",
"style": "powerline",
"foreground": "#193549",
"foreground_templates": [
"{{if eq \"Charging\" .State.String}}#64B5F6{{end}}",
"{{if eq \"Discharging\" .State.String}}#E36464{{end}}",
"{{if eq \"Full\" .State.String}}#66BB6A{{end}}"
],
"properties": {
"battery_icon": "",
"discharging_icon": "\uE231 ",
"charging_icon": "\uE234 ",
"charged_icon": "\uE22F ",
"color_background": false,
"charged_color": "#66BB6A",
"charging_color": "#64B5F6",
"discharging_color": "#E36464",
"prefix": "\u005B",
"postfix": "\uF295\u005D",
"display_charging": true
"postfix": "\uF295\u005D"
}
}
]

View file

@ -88,12 +88,12 @@
"powerline_symbol": "\uE0B2",
"foreground": "#242424",
"background": "#f36943",
"background_templates": [
"{{if eq \"Charging\" .State.String}}#33DD2D{{end}}",
"{{if eq \"Discharging\" .State.String}}#FFCD58{{end}}",
"{{if eq \"Full\" .State.String}}#0476d0{{end}}"
],
"properties": {
"battery_icon": "\f583",
"color_background": true,
"charged_color": "#0476d0",
"charging_color": "#33DD2D",
"discharging_color": "#FFCD58",
"postfix": "\uF295 \uf583 "
}
},

View file

@ -207,15 +207,15 @@
"powerline_symbol": "\uE0B2",
"foreground": "#ffffff",
"background": "#f36943",
"background_templates": [
"{{if eq \"Charging\" .State.String}}#40c4ff{{end}}",
"{{if eq \"Discharging\" .State.String}}#ff5722{{end}}",
"{{if eq \"Full\" .State.String}}#4caf50{{end}}"
],
"properties": {
"battery_icon": "",
"discharging_icon": " ",
"charging_icon": " ",
"charged_icon": " ",
"color_background": true,
"charged_color": "#4caf50",
"charging_color": "#40c4ff",
"discharging_color": "#ff5722",
"postfix": " "
}
},

View file

@ -123,15 +123,15 @@
"powerline_symbol": "\uE0B2",
"foreground": "#ffffff",
"background": "#f36943",
"background_templates": [
"{{if eq \"Charging\" .State.String}}#40c4ff{{end}}",
"{{if eq \"Discharging\" .State.String}}#ff5722{{end}}",
"{{if eq \"Full\" .State.String}}#4caf50{{end}}"
],
"properties": {
"battery_icon": "",
"discharging_icon": "\uF57D ",
"charging_icon": "\uF588 ",
"charged_icon": "\uF583 ",
"color_background": true,
"charged_color": "#4caf50",
"charging_color": "#40c4ff",
"discharging_color": "#ff5722",
"postfix": "% "
}
},

View file

@ -78,12 +78,14 @@
"type": "battery",
"style": "powerline",
"invert_powerline": true,
"foreground_templates": [
"{{if eq \"Charging\" .State.String}}#4caf50{{end}}",
"{{if eq \"Discharging\" .State.String}}#40c4ff{{end}}",
"{{if eq \"Full\" .State.String}}#ff0000{{end}}"
],
"properties": {
"charging_icon": " ",
"charged_icon": "\uf00d ",
"charged_color": "#ff0000",
"charging_color": "#4caf50",
"discharging_color": "#40c4ff",
"prefix": "| ",
"postfix": "  "
}

View file

@ -323,12 +323,6 @@
"properties": {
"properties": {
"properties": {
"battery_icon": {
"type": "string",
"title": "Battery Icon",
"description": "Text/icon to use as a prefix for the battery percentage",
"default": ""
},
"display_error": {
"type": "boolean",
"title": "Display Error",
@ -353,27 +347,6 @@
"description": "Text/icon to display on the left when fully charged",
"default": ""
},
"color_background": {
"type": "boolean",
"title": "Color Background",
"description": "Color the background or foreground",
"default": false
},
"charged_color": { "$ref": "#/definitions/color" },
"charging_color": { "$ref": "#/definitions/color" },
"discharging_color": { "$ref": "#/definitions/color" },
"display_charging": {
"type": "boolean",
"title": "Display while charging",
"description": "displays the battery status while charging (Charging)",
"default": true
},
"display_charged": {
"type": "boolean",
"title": "Display when full",
"description": "displays the battery status when charged (Full)",
"default": true
},
"template": {
"$ref": "#/definitions/template"
}