Skip to content

Commit

Permalink
Fix #1361 - Battery widget debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
heitzmann authored and flacjacket committed Jun 29, 2019
1 parent 024ffc9 commit 1ae7d6f
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions libqtile/widget/battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,21 +218,21 @@ def _get_battery_name(self):
return 'BAT0'

def _load_file(self, name) -> Optional[Tuple[str, str]]:
try:
path = os.path.join(self.BAT_DIR, self.battery, name)
if 'energy' in name or 'power' in name:
value_type = 'uW'
elif 'charge' in name:
value_type = 'uAh'
elif 'current' in name:
value_type = 'uA'
else:
value_type = ''
path = os.path.join(self.BAT_DIR, self.battery, name)
if 'energy' in name or 'power' in name:
value_type = 'uW'
elif 'charge' in name:
value_type = 'uAh'
elif 'current' in name:
value_type = 'uA'
else:
value_type = ''

try:
with open(path, 'r') as f:
return f.read().strip(), value_type
except Exception:
logger.exception("Failed to get %s" % name)
except FileNotFoundError:
logger.debug("Failed to get %s" % name)
return None

def _get_param(self, name) -> Tuple[str, str]:
Expand Down

0 comments on commit 1ae7d6f

Please sign in to comment.