mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-15 13:17:53 -08:00
fix: avoid crash on system with no battey in battery segment
This commit is contained in:
parent
86d2c3c0fa
commit
c57368ce7d
|
@ -37,11 +37,6 @@ const (
|
|||
func (b *batt) enabled() bool {
|
||||
bt, err := b.env.getBatteryInfo()
|
||||
|
||||
display := b.props.getBool(DisplayCharging, true)
|
||||
if !display && (bt.State == battery.Charging || bt.State == battery.Full) {
|
||||
return false
|
||||
}
|
||||
|
||||
displayError := b.props.getBool(DisplayError, false)
|
||||
if err != nil && displayError {
|
||||
b.percentageText = "BATT ERR"
|
||||
|
@ -58,6 +53,12 @@ func (b *batt) enabled() bool {
|
|||
State: battery.Full,
|
||||
}
|
||||
}
|
||||
|
||||
display := b.props.getBool(DisplayCharging, true)
|
||||
if !display && (bt.State == battery.Charging || bt.State == battery.Full) {
|
||||
return false
|
||||
}
|
||||
|
||||
batteryPercentage := bt.Current / bt.Full * 100
|
||||
batteryPercentage = math.Min(100, batteryPercentage)
|
||||
percentageText := fmt.Sprintf("%.0f", batteryPercentage)
|
||||
|
|
Loading…
Reference in a new issue