Skip to content

Commit

Permalink
fix: cap batt percentage at 100
Browse files Browse the repository at this point in the history
resolves #141
  • Loading branch information
JanDeDobbeleer committed Nov 11, 2020
1 parent 284f2cb commit b0c7e66
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions segment_battery.go
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"
"math"

"github.com/distatus/battery"
)
Expand Down Expand Up @@ -42,6 +43,7 @@ func (b *batt) enabled() bool {
return true
}
batteryPercentage := bt.Current / bt.Full * 100
batteryPercentage = math.Min(100, batteryPercentage)
percentageText := fmt.Sprintf("%.0f", batteryPercentage)
var icon string
var colorPorperty Property
Expand Down

0 comments on commit b0c7e66

Please sign in to comment.