mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
refactor(battery): remove legacy properties
This commit is contained in:
parent
fa38b516b1
commit
b94e96dd15
|
@ -128,14 +128,9 @@ _Color override_ ([Battery segment][battery]):
|
||||||
"foreground": "p:white",
|
"foreground": "p:white",
|
||||||
"background": "p:black",
|
"background": "p:black",
|
||||||
"properties": {
|
"properties": {
|
||||||
"battery_icon": "<#ffa500> [II ]- </>", // icon should always be orange
|
"discharging_icon": "<#ffa500>-</> ",
|
||||||
"discharging_icon": "- ",
|
|
||||||
"charging_icon": "+ ",
|
"charging_icon": "+ ",
|
||||||
"charged_icon": "* ",
|
"charged_icon": "* ",
|
||||||
"color_background": true,
|
|
||||||
"charged_color": "#4caf50", //
|
|
||||||
"charging_color": "#40c4ff", // battery should use specific colors for status
|
|
||||||
"discharging_color": "#ff5722", //
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
```
|
```
|
||||||
|
|
|
@ -17,18 +17,17 @@ Battery displays the remaining power percentage for your battery.
|
||||||
"powerline_symbol": "\uE0B0",
|
"powerline_symbol": "\uE0B0",
|
||||||
"foreground": "#193549",
|
"foreground": "#193549",
|
||||||
"background": "#ffeb3b",
|
"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": {
|
"properties": {
|
||||||
"battery_icon": "",
|
|
||||||
"discharging_icon": "\uE231 ",
|
"discharging_icon": "\uE231 ",
|
||||||
"charging_icon": "\uE234 ",
|
"charging_icon": "\uE234 ",
|
||||||
"charged_icon": "\uE22F ",
|
"charged_icon": "\uE22F ",
|
||||||
"color_background": true,
|
|
||||||
"charged_color": "#4caf50",
|
|
||||||
"charging_color": "#40c4ff",
|
|
||||||
"discharging_color": "#ff5722",
|
|
||||||
"postfix": "\uF295 ",
|
"postfix": "\uF295 ",
|
||||||
"display_charging": true,
|
"template": "{{ if not .Error }}{{.Icon}}{{.Percentage}}{{ end }}"
|
||||||
"display_charged": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -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
|
- 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
|
- 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
|
- 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
|
## 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
|
- `.Percentage`: `float64` - the current battery percentage
|
||||||
- `.Error`: `string` - the error in case fetching the battery information failed
|
- `.Error`: `string` - the error in case fetching the battery information failed
|
||||||
- `.Icon`: `string` - the icon based on the battery state
|
- `.Icon`: `string` - the icon based on the battery state
|
||||||
|
|
|
@ -23,16 +23,6 @@ const (
|
||||||
DischargingIcon Property = "discharging_icon"
|
DischargingIcon Property = "discharging_icon"
|
||||||
// ChargedIcon to display when fully charged
|
// ChargedIcon to display when fully charged
|
||||||
ChargedIcon Property = "charged_icon"
|
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 {
|
func (b *batt) enabled() bool {
|
||||||
|
@ -52,38 +42,24 @@ func (b *batt) enabled() bool {
|
||||||
b.Battery.Full += bt.Full
|
b.Battery.Full += bt.Full
|
||||||
b.Battery.State = b.mapMostLogicalState(b.Battery.State, bt.State)
|
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
|
batteryPercentage := b.Battery.Current / b.Battery.Full * 100
|
||||||
b.Percentage = int(math.Min(100, batteryPercentage))
|
b.Percentage = int(math.Min(100, batteryPercentage))
|
||||||
var colorPorperty Property
|
|
||||||
|
if !b.shouldDisplay() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
switch b.Battery.State {
|
switch b.Battery.State {
|
||||||
case battery.Discharging, battery.NotCharging:
|
case battery.Discharging, battery.NotCharging:
|
||||||
colorPorperty = DischargingColor
|
|
||||||
b.Icon = b.props.getString(DischargingIcon, "")
|
b.Icon = b.props.getString(DischargingIcon, "")
|
||||||
case battery.Charging:
|
case battery.Charging:
|
||||||
colorPorperty = ChargingColor
|
|
||||||
b.Icon = b.props.getString(ChargingIcon, "")
|
b.Icon = b.props.getString(ChargingIcon, "")
|
||||||
case battery.Full:
|
case battery.Full:
|
||||||
colorPorperty = ChargedColor
|
|
||||||
b.Icon = b.props.getString(ChargedIcon, "")
|
b.Icon = b.props.getString(ChargedIcon, "")
|
||||||
case battery.Empty, battery.Unknown:
|
case battery.Empty, battery.Unknown:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
colorBackground := b.props.getBool(ColorBackground, false)
|
b.colorSegment()
|
||||||
if colorBackground {
|
|
||||||
b.props.background = b.props.getColor(colorPorperty, b.props.background)
|
|
||||||
} else {
|
|
||||||
b.props.foreground = b.props.getColor(colorPorperty, b.props.foreground)
|
|
||||||
}
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/distatus/battery"
|
"github.com/distatus/battery"
|
||||||
|
@ -14,137 +13,6 @@ const (
|
||||||
chargedColor = "#248644"
|
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) {
|
func TestGetBatteryColors(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
|
|
|
@ -4,8 +4,29 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"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
|
// GIT Segement
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -45,14 +66,6 @@ const (
|
||||||
StatusSeparatorIcon Property = "status_separator_icon"
|
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 {
|
func (g *git) deprecatedString(statusColorsEnabled bool) string {
|
||||||
if statusColorsEnabled {
|
if statusColorsEnabled {
|
||||||
g.SetStatusColor()
|
g.SetStatusColor()
|
||||||
|
@ -166,3 +179,56 @@ func (e *exit) deprecatedString() string {
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%s%s", errorIcon, e.Text)
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/distatus/battery"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -301,3 +303,136 @@ func TestExitWriterDeprecatedString(t *testing.T) {
|
||||||
assert.Equal(t, tc.Expected, e.string())
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -185,20 +185,20 @@ func (g *git) shouldIgnoreRootRepository(rootDir string) bool {
|
||||||
|
|
||||||
func (g *git) string() string {
|
func (g *git) string() string {
|
||||||
statusColorsEnabled := g.props.getBool(StatusColorsEnabled, false)
|
statusColorsEnabled := g.props.getBool(StatusColorsEnabled, false)
|
||||||
displayStatus := g.getBool(FetchStatus, DisplayStatus)
|
displayStatus := g.props.getOneOfBool(FetchStatus, DisplayStatus)
|
||||||
if !displayStatus {
|
if !displayStatus {
|
||||||
g.HEAD = g.getPrettyHEADName()
|
g.HEAD = g.getPrettyHEADName()
|
||||||
}
|
}
|
||||||
if displayStatus || statusColorsEnabled {
|
if displayStatus || statusColorsEnabled {
|
||||||
g.setGitStatus()
|
g.setGitStatus()
|
||||||
}
|
}
|
||||||
if g.Upstream != "" && g.getBool(FetchUpstreamIcon, DisplayUpstreamIcon) {
|
if g.Upstream != "" && g.props.getOneOfBool(FetchUpstreamIcon, DisplayUpstreamIcon) {
|
||||||
g.UpstreamIcon = g.getUpstreamIcon()
|
g.UpstreamIcon = g.getUpstreamIcon()
|
||||||
}
|
}
|
||||||
if g.getBool(FetchStashCount, DisplayStashCount) {
|
if g.props.getOneOfBool(FetchStashCount, DisplayStashCount) {
|
||||||
g.StashCount = g.getStashContext()
|
g.StashCount = g.getStashContext()
|
||||||
}
|
}
|
||||||
if g.getBool(FetchWorktreeCount, DisplayWorktreeCount) {
|
if g.props.getOneOfBool(FetchWorktreeCount, DisplayWorktreeCount) {
|
||||||
g.WorktreeCount = g.getWorktreeContext()
|
g.WorktreeCount = g.getWorktreeContext()
|
||||||
}
|
}
|
||||||
// use template if available
|
// use template if available
|
||||||
|
|
90
src/testdata/jandedobbeleer-palette.omp.json
vendored
90
src/testdata/jandedobbeleer-palette.omp.json
vendored
|
@ -38,8 +38,8 @@
|
||||||
{
|
{
|
||||||
"type": "session",
|
"type": "session",
|
||||||
"style": "diamond",
|
"style": "diamond",
|
||||||
"foreground": "palette:white",
|
"foreground": "p:white",
|
||||||
"background": "palette:session",
|
"background": "p:session",
|
||||||
"leading_diamond": "",
|
"leading_diamond": "",
|
||||||
"trailing_diamond": "\uE0B0",
|
"trailing_diamond": "\uE0B0",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
@ -51,8 +51,8 @@
|
||||||
"type": "path",
|
"type": "path",
|
||||||
"style": "powerline",
|
"style": "powerline",
|
||||||
"powerline_symbol": "\uE0B0",
|
"powerline_symbol": "\uE0B0",
|
||||||
"foreground": "palette:white",
|
"foreground": "p:white",
|
||||||
"background": "palette:path",
|
"background": "p:path",
|
||||||
"properties": {
|
"properties": {
|
||||||
"prefix": " ",
|
"prefix": " ",
|
||||||
"home_icon": "~",
|
"home_icon": "~",
|
||||||
|
@ -64,13 +64,13 @@
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"style": "powerline",
|
"style": "powerline",
|
||||||
"powerline_symbol": "\uE0B0",
|
"powerline_symbol": "\uE0B0",
|
||||||
"foreground": "palette:git-foreground",
|
"foreground": "p:git-foreground",
|
||||||
"background": "palette:git",
|
"background": "p:git",
|
||||||
"background_templates": [
|
"background_templates": [
|
||||||
"{{ if or (.Working.Changed) (.Staging.Changed) }}palette:git-modified{{ end }}",
|
"{{ if or (.Working.Changed) (.Staging.Changed) }}p:git-modified{{ end }}",
|
||||||
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}palette:git-diverged{{ end }}",
|
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}p:git-diverged{{ end }}",
|
||||||
"{{ if gt .Ahead 0 }}palette:git-ahead{{ end }}",
|
"{{ if gt .Ahead 0 }}p:git-ahead{{ end }}",
|
||||||
"{{ if gt .Behind 0 }}palette:git-behind{{ end }}"
|
"{{ if gt .Behind 0 }}p:git-behind{{ end }}"
|
||||||
],
|
],
|
||||||
"leading_diamond": "",
|
"leading_diamond": "",
|
||||||
"trailing_diamond": "",
|
"trailing_diamond": "",
|
||||||
|
@ -86,8 +86,8 @@
|
||||||
"type": "node",
|
"type": "node",
|
||||||
"style": "powerline",
|
"style": "powerline",
|
||||||
"powerline_symbol": "\uE0B0",
|
"powerline_symbol": "\uE0B0",
|
||||||
"foreground": "palette:white",
|
"foreground": "p:white",
|
||||||
"background": "palette:node",
|
"background": "p:node",
|
||||||
"properties": {
|
"properties": {
|
||||||
"prefix": " \uF898 ",
|
"prefix": " \uF898 ",
|
||||||
"display_version": true
|
"display_version": true
|
||||||
|
@ -97,8 +97,8 @@
|
||||||
"type": "go",
|
"type": "go",
|
||||||
"style": "powerline",
|
"style": "powerline",
|
||||||
"powerline_symbol": "\uE0B0",
|
"powerline_symbol": "\uE0B0",
|
||||||
"foreground": "palette:black",
|
"foreground": "p:black",
|
||||||
"background": "palette:go",
|
"background": "p:go",
|
||||||
"properties": {
|
"properties": {
|
||||||
"prefix": " \uE626 ",
|
"prefix": " \uE626 ",
|
||||||
"display_version": true
|
"display_version": true
|
||||||
|
@ -108,8 +108,8 @@
|
||||||
"type": "julia",
|
"type": "julia",
|
||||||
"style": "powerline",
|
"style": "powerline",
|
||||||
"powerline_symbol": "\uE0B0",
|
"powerline_symbol": "\uE0B0",
|
||||||
"foreground": "palette:black",
|
"foreground": "p:black",
|
||||||
"background": "palette:julia",
|
"background": "p:julia",
|
||||||
"properties": {
|
"properties": {
|
||||||
"prefix": " \uE624 ",
|
"prefix": " \uE624 ",
|
||||||
"display_version": true
|
"display_version": true
|
||||||
|
@ -119,8 +119,8 @@
|
||||||
"type": "python",
|
"type": "python",
|
||||||
"style": "powerline",
|
"style": "powerline",
|
||||||
"powerline_symbol": "\uE0B0",
|
"powerline_symbol": "\uE0B0",
|
||||||
"foreground": "palette:black",
|
"foreground": "p:black",
|
||||||
"background": "palette:python",
|
"background": "p:python",
|
||||||
"properties": {
|
"properties": {
|
||||||
"prefix": " \uE235 ",
|
"prefix": " \uE235 ",
|
||||||
"display_version": true,
|
"display_version": true,
|
||||||
|
@ -132,8 +132,8 @@
|
||||||
"type": "ruby",
|
"type": "ruby",
|
||||||
"style": "powerline",
|
"style": "powerline",
|
||||||
"powerline_symbol": "\uE0B0",
|
"powerline_symbol": "\uE0B0",
|
||||||
"foreground": "palette:white",
|
"foreground": "p:white",
|
||||||
"background": "palette:ruby",
|
"background": "p:ruby",
|
||||||
"properties": {
|
"properties": {
|
||||||
"prefix": " \uE791 ",
|
"prefix": " \uE791 ",
|
||||||
"display_version": true,
|
"display_version": true,
|
||||||
|
@ -144,8 +144,8 @@
|
||||||
"type": "azfunc",
|
"type": "azfunc",
|
||||||
"style": "powerline",
|
"style": "powerline",
|
||||||
"powerline_symbol": "\uE0B0",
|
"powerline_symbol": "\uE0B0",
|
||||||
"foreground": "palette:white",
|
"foreground": "p:white",
|
||||||
"background": "palette:azfunc",
|
"background": "p:azfunc",
|
||||||
"properties": {
|
"properties": {
|
||||||
"prefix": " \uf0e7",
|
"prefix": " \uf0e7",
|
||||||
"display_version": false,
|
"display_version": false,
|
||||||
|
@ -156,10 +156,10 @@
|
||||||
"type": "aws",
|
"type": "aws",
|
||||||
"style": "powerline",
|
"style": "powerline",
|
||||||
"powerline_symbol": "\uE0B0",
|
"powerline_symbol": "\uE0B0",
|
||||||
"foreground": "palette:white",
|
"foreground": "p:white",
|
||||||
"background_templates": [
|
"background_templates": [
|
||||||
"{{if contains \"default\" .Profile}}palette:aws-default{{end}}",
|
"{{if contains \"default\" .Profile}}p:aws-default{{end}}",
|
||||||
"{{if contains \"jan\" .Profile}}palette:aws-jan{{end}}"
|
"{{if contains \"jan\" .Profile}}p:aws-jan{{end}}"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"prefix": " \uE7AD ",
|
"prefix": " \uE7AD ",
|
||||||
|
@ -170,8 +170,8 @@
|
||||||
"type": "root",
|
"type": "root",
|
||||||
"style": "powerline",
|
"style": "powerline",
|
||||||
"powerline_symbol": "\uE0B0",
|
"powerline_symbol": "\uE0B0",
|
||||||
"foreground": "palette:black",
|
"foreground": "p:black",
|
||||||
"background": "palette:root",
|
"background": "p:root",
|
||||||
"properties": {
|
"properties": {
|
||||||
"root_icon": ""
|
"root_icon": ""
|
||||||
}
|
}
|
||||||
|
@ -179,8 +179,8 @@
|
||||||
{
|
{
|
||||||
"type": "executiontime",
|
"type": "executiontime",
|
||||||
"style": "plain",
|
"style": "plain",
|
||||||
"foreground": "palette:white",
|
"foreground": "p:white",
|
||||||
"background": "palette:executiontime",
|
"background": "p:executiontime",
|
||||||
"leading_diamond": "",
|
"leading_diamond": "",
|
||||||
"trailing_diamond": "",
|
"trailing_diamond": "",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
@ -192,10 +192,10 @@
|
||||||
{
|
{
|
||||||
"type": "exit",
|
"type": "exit",
|
||||||
"style": "diamond",
|
"style": "diamond",
|
||||||
"foreground": "palette:white",
|
"foreground": "p:white",
|
||||||
"background": "palette:exit",
|
"background": "p:exit",
|
||||||
"background_templates": [
|
"background_templates": [
|
||||||
"{{ if gt .Code 0 }}palette:exit-red{{ end }}"
|
"{{ if gt .Code 0 }}p:exit-red{{ end }}"
|
||||||
],
|
],
|
||||||
"leading_diamond": "",
|
"leading_diamond": "",
|
||||||
"trailing_diamond": "\uE0B4",
|
"trailing_diamond": "\uE0B4",
|
||||||
|
@ -213,8 +213,8 @@
|
||||||
{
|
{
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"style": "plain",
|
"style": "plain",
|
||||||
"foreground": "palette:white",
|
"foreground": "p:white",
|
||||||
"background": "palette:shell",
|
"background": "p:shell",
|
||||||
"properties": {
|
"properties": {
|
||||||
"prefix": "<#0077c2,transparent>\uE0B6</> ",
|
"prefix": "<#0077c2,transparent>\uE0B6</> ",
|
||||||
"postfix": " <transparent,#0077c2>\uE0B2</>"
|
"postfix": " <transparent,#0077c2>\uE0B2</>"
|
||||||
|
@ -225,8 +225,8 @@
|
||||||
"style": "powerline",
|
"style": "powerline",
|
||||||
"powerline_symbol": "\uE0B2",
|
"powerline_symbol": "\uE0B2",
|
||||||
"invert_powerline": true,
|
"invert_powerline": true,
|
||||||
"foreground": "palette:black",
|
"foreground": "p:black",
|
||||||
"background": "palette:ytm",
|
"background": "p:ytm",
|
||||||
"properties": {
|
"properties": {
|
||||||
"prefix": " \uF167 ",
|
"prefix": " \uF167 ",
|
||||||
"paused_icon": " ",
|
"paused_icon": " ",
|
||||||
|
@ -238,17 +238,17 @@
|
||||||
"style": "powerline",
|
"style": "powerline",
|
||||||
"invert_powerline": true,
|
"invert_powerline": true,
|
||||||
"powerline_symbol": "\uE0B2",
|
"powerline_symbol": "\uE0B2",
|
||||||
"foreground": "palette:white",
|
"foreground": "p:white",
|
||||||
"background": "palette:battery",
|
"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": {
|
"properties": {
|
||||||
"battery_icon": "",
|
|
||||||
"discharging_icon": " ",
|
"discharging_icon": " ",
|
||||||
"charging_icon": " ",
|
"charging_icon": " ",
|
||||||
"charged_icon": " ",
|
"charged_icon": " ",
|
||||||
"color_background": true,
|
|
||||||
"charged_color": "palette:battery-charged",
|
|
||||||
"charging_color": "palette:battery-charging",
|
|
||||||
"discharging_color": "palette:battery-discharging",
|
|
||||||
"postfix": " "
|
"postfix": " "
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -258,8 +258,8 @@
|
||||||
"invert_powerline": true,
|
"invert_powerline": true,
|
||||||
"leading_diamond": "\uE0B2",
|
"leading_diamond": "\uE0B2",
|
||||||
"trailing_diamond": "\uE0B4",
|
"trailing_diamond": "\uE0B4",
|
||||||
"background": "palette:time",
|
"background": "p:time",
|
||||||
"foreground": "palette:black"
|
"foreground": "p:black"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
10
src/testdata/jandedobbeleer.omp.json
vendored
10
src/testdata/jandedobbeleer.omp.json
vendored
|
@ -207,15 +207,15 @@
|
||||||
"powerline_symbol": "\uE0B2",
|
"powerline_symbol": "\uE0B2",
|
||||||
"foreground": "#ffffff",
|
"foreground": "#ffffff",
|
||||||
"background": "#f36943",
|
"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": {
|
"properties": {
|
||||||
"battery_icon": "",
|
|
||||||
"discharging_icon": " ",
|
"discharging_icon": " ",
|
||||||
"charging_icon": " ",
|
"charging_icon": " ",
|
||||||
"charged_icon": " ",
|
"charged_icon": " ",
|
||||||
"color_background": true,
|
|
||||||
"charged_color": "#4caf50",
|
|
||||||
"charging_color": "#40c4ff",
|
|
||||||
"discharging_color": "#ff5722",
|
|
||||||
"postfix": " "
|
"postfix": " "
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -266,15 +266,15 @@
|
||||||
"trailing_diamond": "",
|
"trailing_diamond": "",
|
||||||
"foreground": "#262626",
|
"foreground": "#262626",
|
||||||
"background": "#f36943",
|
"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": {
|
"properties": {
|
||||||
"battery_icon": "",
|
|
||||||
"discharging_icon": " ",
|
"discharging_icon": " ",
|
||||||
"charging_icon": "\uf1e6 ",
|
"charging_icon": "\uf1e6 ",
|
||||||
"charged_icon": "\uf58e ",
|
"charged_icon": "\uf58e ",
|
||||||
"color_background": true,
|
|
||||||
"charged_color": "#33DD2D",
|
|
||||||
"charging_color": "#b8e994",
|
|
||||||
"discharging_color": "#fff34e",
|
|
||||||
"postfix": " <#262626>\uE0B2</>"
|
"postfix": " <#262626>\uE0B2</>"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -182,14 +182,16 @@
|
||||||
{
|
{
|
||||||
"type": "battery",
|
"type": "battery",
|
||||||
"style": "plain",
|
"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": {
|
"properties": {
|
||||||
"discharging_icon": " ",
|
"discharging_icon": " ",
|
||||||
"charging_icon": "\uf1e6 ",
|
"charging_icon": "\uf1e6 ",
|
||||||
"charged_icon": "\uf58e ",
|
"charged_icon": "\uf58e ",
|
||||||
"color_foreground": true,
|
|
||||||
"charged_color": "#33DD2D",
|
|
||||||
"charging_color": "#40c4ff",
|
|
||||||
"discharging_color": "#FFFB38",
|
|
||||||
"prefix": "<#ffffff>[</>",
|
"prefix": "<#ffffff>[</>",
|
||||||
"postfix": "%<#ffffff>]─</>"
|
"postfix": "%<#ffffff>]─</>"
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,12 +30,12 @@
|
||||||
"powerline_symbol": "\uE0B0",
|
"powerline_symbol": "\uE0B0",
|
||||||
"foreground": "#193549",
|
"foreground": "#193549",
|
||||||
"background": "#a2beef",
|
"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": {
|
"properties": {
|
||||||
"battery_icon": "\f583",
|
|
||||||
"color_background": true,
|
|
||||||
"charged_color": "#0476d0",
|
|
||||||
"charging_color": "#00D100",
|
|
||||||
"discharging_color": "#FFCD58",
|
|
||||||
"postfix": "\uF295 \uf583 "
|
"postfix": "\uF295 \uf583 "
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -130,18 +130,17 @@
|
||||||
"leading_diamond": " \uE0B6",
|
"leading_diamond": " \uE0B6",
|
||||||
"foreground": "#9B6BDF",
|
"foreground": "#9B6BDF",
|
||||||
"background": "#29315A",
|
"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": {
|
"properties": {
|
||||||
"battery_icon": "",
|
|
||||||
"discharging_icon": "\u21E3 ",
|
"discharging_icon": "\u21E3 ",
|
||||||
"charging_icon": "\u21E1 ",
|
"charging_icon": "\u21E1 ",
|
||||||
"charged_icon": "\u0095 ",
|
"charged_icon": "\u0095 ",
|
||||||
"color_background": false,
|
|
||||||
"charged_color": "#4caf50",
|
|
||||||
"charging_color": "#40c4ff",
|
|
||||||
"discharging_color": "#ff5722",
|
|
||||||
"prefix": "",
|
"prefix": "",
|
||||||
"postfix": "",
|
"postfix": ""
|
||||||
"display_charging": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -117,18 +117,17 @@
|
||||||
"leading_diamond": " \uE0B6",
|
"leading_diamond": " \uE0B6",
|
||||||
"foreground": "#9B6BDF",
|
"foreground": "#9B6BDF",
|
||||||
"background": "#424242",
|
"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": {
|
"properties": {
|
||||||
"battery_icon": "",
|
|
||||||
"discharging_icon": "\u21E3 ",
|
"discharging_icon": "\u21E3 ",
|
||||||
"charging_icon": "\u21E1 ",
|
"charging_icon": "\u21E1 ",
|
||||||
"charged_icon": "\u25CF ",
|
"charged_icon": "\u25CF ",
|
||||||
"color_background": false,
|
|
||||||
"charged_color": "#4caf50",
|
|
||||||
"charging_color": "#40c4ff",
|
|
||||||
"discharging_color": "#ff5722",
|
|
||||||
"prefix": "",
|
"prefix": "",
|
||||||
"postfix": "",
|
"postfix": ""
|
||||||
"display_charging": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -76,18 +76,17 @@
|
||||||
"type": "battery",
|
"type": "battery",
|
||||||
"style": "powerline",
|
"style": "powerline",
|
||||||
"foreground": "#193549",
|
"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": {
|
"properties": {
|
||||||
"battery_icon": "",
|
|
||||||
"discharging_icon": "\uE231 ",
|
"discharging_icon": "\uE231 ",
|
||||||
"charging_icon": "\uE234 ",
|
"charging_icon": "\uE234 ",
|
||||||
"charged_icon": "\uE22F ",
|
"charged_icon": "\uE22F ",
|
||||||
"color_background": false,
|
|
||||||
"charged_color": "#66BB6A",
|
|
||||||
"charging_color": "#64B5F6",
|
|
||||||
"discharging_color": "#E36464",
|
|
||||||
"prefix": "\u005B",
|
"prefix": "\u005B",
|
||||||
"postfix": "\uF295\u005D",
|
"postfix": "\uF295\u005D"
|
||||||
"display_charging": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -88,12 +88,12 @@
|
||||||
"powerline_symbol": "\uE0B2",
|
"powerline_symbol": "\uE0B2",
|
||||||
"foreground": "#242424",
|
"foreground": "#242424",
|
||||||
"background": "#f36943",
|
"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": {
|
"properties": {
|
||||||
"battery_icon": "\f583",
|
|
||||||
"color_background": true,
|
|
||||||
"charged_color": "#0476d0",
|
|
||||||
"charging_color": "#33DD2D",
|
|
||||||
"discharging_color": "#FFCD58",
|
|
||||||
"postfix": "\uF295 \uf583 "
|
"postfix": "\uF295 \uf583 "
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -207,15 +207,15 @@
|
||||||
"powerline_symbol": "\uE0B2",
|
"powerline_symbol": "\uE0B2",
|
||||||
"foreground": "#ffffff",
|
"foreground": "#ffffff",
|
||||||
"background": "#f36943",
|
"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": {
|
"properties": {
|
||||||
"battery_icon": "",
|
|
||||||
"discharging_icon": " ",
|
"discharging_icon": " ",
|
||||||
"charging_icon": " ",
|
"charging_icon": " ",
|
||||||
"charged_icon": " ",
|
"charged_icon": " ",
|
||||||
"color_background": true,
|
|
||||||
"charged_color": "#4caf50",
|
|
||||||
"charging_color": "#40c4ff",
|
|
||||||
"discharging_color": "#ff5722",
|
|
||||||
"postfix": " "
|
"postfix": " "
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -123,15 +123,15 @@
|
||||||
"powerline_symbol": "\uE0B2",
|
"powerline_symbol": "\uE0B2",
|
||||||
"foreground": "#ffffff",
|
"foreground": "#ffffff",
|
||||||
"background": "#f36943",
|
"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": {
|
"properties": {
|
||||||
"battery_icon": "",
|
|
||||||
"discharging_icon": "\uF57D ",
|
"discharging_icon": "\uF57D ",
|
||||||
"charging_icon": "\uF588 ",
|
"charging_icon": "\uF588 ",
|
||||||
"charged_icon": "\uF583 ",
|
"charged_icon": "\uF583 ",
|
||||||
"color_background": true,
|
|
||||||
"charged_color": "#4caf50",
|
|
||||||
"charging_color": "#40c4ff",
|
|
||||||
"discharging_color": "#ff5722",
|
|
||||||
"postfix": "% "
|
"postfix": "% "
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -78,12 +78,14 @@
|
||||||
"type": "battery",
|
"type": "battery",
|
||||||
"style": "powerline",
|
"style": "powerline",
|
||||||
"invert_powerline": true,
|
"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": {
|
"properties": {
|
||||||
"charging_icon": " ",
|
"charging_icon": " ",
|
||||||
"charged_icon": "\uf00d ",
|
"charged_icon": "\uf00d ",
|
||||||
"charged_color": "#ff0000",
|
|
||||||
"charging_color": "#4caf50",
|
|
||||||
"discharging_color": "#40c4ff",
|
|
||||||
"prefix": "| ",
|
"prefix": "| ",
|
||||||
"postfix": " "
|
"postfix": " "
|
||||||
}
|
}
|
||||||
|
|
|
@ -323,12 +323,6 @@
|
||||||
"properties": {
|
"properties": {
|
||||||
"properties": {
|
"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": {
|
"display_error": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"title": "Display Error",
|
"title": "Display Error",
|
||||||
|
@ -353,27 +347,6 @@
|
||||||
"description": "Text/icon to display on the left when fully charged",
|
"description": "Text/icon to display on the left when fully charged",
|
||||||
"default": ""
|
"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": {
|
"template": {
|
||||||
"$ref": "#/definitions/template"
|
"$ref": "#/definitions/template"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue