i3-companion: cleaner way to format bluetooth widget

This commit is contained in:
Vincent Bernat 2022-03-26 22:34:52 +01:00
parent 6e7d529abf
commit 5d85f8db80

View file

@ -857,7 +857,7 @@ async def bluetooth_status(i3, event, *args):
sock.close() sock.close()
# Choose an icon # Choose an icon
icon = f"battery-{(battery+12)//25*25}" icon = f"battery-{(battery+12)//25*25}"
output[-1] = f"{output[-1]},{icon}" output[-1] = (output[-1], icon)
# Schedule a refresh in 5 minutes # Schedule a refresh in 5 minutes
bluetooth_status.scheduled = loop.call_later( bluetooth_status.scheduled = loop.call_later(
600, 600,
@ -865,7 +865,10 @@ async def bluetooth_status(i3, event, *args):
) )
except Exception as exc: except Exception as exc:
logger.info("cannot get battery status: %s", exc) logger.info("cannot get battery status: %s", exc)
return "|".join(" ".join(icons[oo] for oo in o.split(",")) for o in output) return "|".join(
(" ".join(icons[oo] for oo in o) if type(o) is tuple else icons[o])
for o in output
)
@on( @on(