Skip to content

Commit

Permalink
battery: only average nonzero battery percentages
Browse files Browse the repository at this point in the history
Fixes: vivien#117
  • Loading branch information
kb100 committed Oct 16, 2017
1 parent ab11640 commit 150f4b9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions battery/battery
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@ else:
if battery!='':
state_batteries.append(battery.split(": ")[1].split(", ")[0])
commasplitstatus = battery.split(", ")
percentleft_batteries.append(int(commasplitstatus[1].rstrip("%\n")))
p = int(commasplitstatus[1].rstrip("%\n"))
if p>0:
percentleft_batteries.append(p)
commasplitstatus_batteries.append(commasplitstatus)
state = state_batteries[0]
commasplitstatus = commasplitstatus_batteries[0]
percentleft = int(sum(percentleft_batteries)/len(percentleft_batteries))
if percentleft_batteries:
percentleft = int(sum(percentleft_batteries)/len(percentleft_batteries))
else:
percentleft = 0

# stands for charging
FA_LIGHTNING = "<span color='yellow'><span font='FontAwesome'>\uf0e7</span></span>"
Expand Down

0 comments on commit 150f4b9

Please sign in to comment.