hidpp20: fix error when showing battery
Signed-off-by: Filipe Laíns <lains@archlinux.org>
This commit is contained in:
parent
c30f0a79bd
commit
0198d58dc7
|
@ -166,7 +166,6 @@ def _print_device(dev):
|
|||
print (' %s, pos:%d, group:%1d, gmask:%d' % ( ', '.join(flags), k.pos, k.group, k.group_mask))
|
||||
if dev.online:
|
||||
battery = _hidpp20.get_battery(dev)
|
||||
(voltage, charging, charge_sts, charge_lvl, charge_type) = _hidpp20.get_voltage(dev)
|
||||
if battery is None:
|
||||
battery = _hidpp10.get_battery(dev)
|
||||
if battery is not None:
|
||||
|
@ -180,10 +179,13 @@ def _print_device(dev):
|
|||
else:
|
||||
text = 'N/A'
|
||||
print (' Battery: %s, %s.' % (text, status))
|
||||
elif voltage:
|
||||
print (' Battery: %smV, %s.' % (voltage, 'Charging' if charging else 'Discharging'))
|
||||
else:
|
||||
print (' Battery status unavailable.')
|
||||
battery_voltage = _hidpp20.get_voltage(dev)
|
||||
if battery_voltage :
|
||||
(voltage, charging, charge_sts, charge_lvl, charge_type) = battery_voltage
|
||||
print (' Battery: %smV, %s.' % (voltage, 'Charging' if charging else 'Discharging'))
|
||||
else:
|
||||
print (' Battery status unavailable.')
|
||||
else:
|
||||
print (' Battery: unknown (device is offline).')
|
||||
|
||||
|
|
Loading…
Reference in New Issue