From 5d85f8db80c4cce585f3b42be07d65df3e2f6aaf Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Sat, 26 Mar 2022 22:34:52 +0100 Subject: [PATCH] i3-companion: cleaner way to format bluetooth widget --- bin/i3-companion | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/i3-companion b/bin/i3-companion index d1b5d6b..761474b 100755 --- a/bin/i3-companion +++ b/bin/i3-companion @@ -857,7 +857,7 @@ async def bluetooth_status(i3, event, *args): sock.close() # Choose an icon icon = f"battery-{(battery+12)//25*25}" - output[-1] = f"{output[-1]},{icon}" + output[-1] = (output[-1], icon) # Schedule a refresh in 5 minutes bluetooth_status.scheduled = loop.call_later( 600, @@ -865,7 +865,10 @@ async def bluetooth_status(i3, event, *args): ) except Exception as 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(