ui: fix bug in determining tray icon
This commit is contained in:
parent
24223e77c7
commit
569f829a63
|
@ -200,7 +200,6 @@ try:
|
||||||
battery_level = device.battery_info.level if device.battery_info is not None else None
|
battery_level = device.battery_info.level if device.battery_info is not None else None
|
||||||
battery_charging = device.battery_info.charging() if device.battery_info is not None else None
|
battery_charging = device.battery_info.charging() if device.battery_info is not None else None
|
||||||
tray_icon_name = _icons.battery(battery_level, battery_charging)
|
tray_icon_name = _icons.battery(battery_level, battery_charging)
|
||||||
|
|
||||||
description = "%s: %s" % (name, device.status_string())
|
description = "%s: %s" % (name, device.status_string())
|
||||||
else:
|
else:
|
||||||
# there may be a receiver, but no peripherals
|
# there may be a receiver, but no peripherals
|
||||||
|
@ -330,8 +329,7 @@ def _pick_device_with_lowest_battery():
|
||||||
for info in _devices_info:
|
for info in _devices_info:
|
||||||
if info[1] is None: # is receiver
|
if info[1] is None: # is receiver
|
||||||
continue
|
continue
|
||||||
level = info[-1].battery_info.level if hasattr(info[-1], "status") and info[-1].battery_info is not None else None
|
level = info[-1].battery_info.level if info[-1].battery_info is not None else None
|
||||||
# print ("checking %s -> %s", info, level)
|
|
||||||
if level is not None and picked_level > level:
|
if level is not None and picked_level > level:
|
||||||
picked = info
|
picked = info
|
||||||
picked_level = level or 0
|
picked_level = level or 0
|
||||||
|
@ -446,7 +444,7 @@ def _update_menu_item(index, device):
|
||||||
_picked_device = None
|
_picked_device = None
|
||||||
|
|
||||||
# cached list of devices and some of their properties
|
# cached list of devices and some of their properties
|
||||||
# contains tuples of (receiver path, device number, name, status)
|
# contains tuples of (receiver path, device number, name, device)
|
||||||
_devices_info = []
|
_devices_info = []
|
||||||
|
|
||||||
_menu = None
|
_menu = None
|
||||||
|
|
Loading…
Reference in New Issue