mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-27 11:59:40 -08:00
fix(battery): count all battery information
This commit is contained in:
parent
0077eb24ff
commit
ee93191aac
|
@ -240,7 +240,26 @@ func (env *environment) getArgs() *args {
|
|||
}
|
||||
|
||||
func (env *environment) getBatteryInfo() (*battery.Battery, error) {
|
||||
return battery.Get(0)
|
||||
getMostLogicalState := func(currentState battery.State, state battery.State) battery.State {
|
||||
if currentState == battery.Unknown {
|
||||
return state
|
||||
}
|
||||
if currentState == battery.Empty|battery.Full && state == battery.Charging|battery.Discharging {
|
||||
return state
|
||||
}
|
||||
return battery.Charging
|
||||
}
|
||||
batteries, err := battery.GetAll()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
batt := &battery.Battery{}
|
||||
for _, bt := range batteries {
|
||||
batt.Current += bt.Current
|
||||
batt.Full += bt.Full
|
||||
batt.State = getMostLogicalState(batt.State, bt.State)
|
||||
}
|
||||
return batt, nil
|
||||
}
|
||||
|
||||
func (env *environment) getShellName() string {
|
||||
|
|
Loading…
Reference in a new issue