Separate battery percentages #1920

This commit is contained in:
nicolargo 2021-08-21 11:20:06 +02:00
parent b466356f3c
commit a0d7db5abb
1 changed files with 13 additions and 7 deletions

View File

@ -108,14 +108,23 @@ class GlancesGrabBat(object):
def update(self):
"""Update the stats."""
self.bat_list = []
if batinfo_tag:
# Use the batinfo lib to grab the stats
# Compatible with multiple batteries
self.bat.update()
self.bat_list = [{
'label': 'Battery',
'value': self.battery_percent,
'unit': '%'}]
# Batinfo support multiple batteries
# ... so take it into account (see #1920)
# self.bat_list = [{
# 'label': 'Battery',
# 'value': self.battery_percent,
# 'unit': '%'}]
for b in self.bat.stat:
self.bat_list.append({
'label': 'BAT {}'.format(b.path.split('/')[-1]),
'value': b.capacity,
'unit': '%'
})
elif psutil_tag and hasattr(self.bat.sensors_battery(), 'percent'):
# Use psutil to grab the stats
# Give directly the battery percent
@ -123,9 +132,6 @@ class GlancesGrabBat(object):
'label': 'Battery',
'value': int(self.bat.sensors_battery().percent),
'unit': '%'}]
else:
# No stats...
self.bat_list = []
def get(self):
"""Get the stats."""