From 3f915404a8166bf9212d92688aa2d324134ba8ce Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Wed, 16 Mar 2022 19:54:24 +0100 Subject: [PATCH] i3-companion: handle absence of Bluetooth class on a device This seems to happen on first pairing. --- bin/i3-companion | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bin/i3-companion b/bin/i3-companion index b62d6a2..e0b7b46 100755 --- a/bin/i3-companion +++ b/bin/i3-companion @@ -765,10 +765,13 @@ async def bluetooth_status(i3, event, *args): device = interfaces["org.bluez.Device1"] if not device["Connected"][1]: continue - device_class = device["Class"][1] - major = (device_class & 0x1F00) >> 8 - minor = (device_class & 0xFC) >> 2 - devices.append((major, minor)) + try: + device_class = device["Class"][1] + major = (device_class & 0x1F00) >> 8 + minor = (device_class & 0xFC) >> 2 + devices.append((major, minor)) + except KeyError: + devices.append((0, 0)) # Choose appropriate icons for output # See: https://btprodspecificationrefs.blob.core.windows.net/assigned-numbers