mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-08-15 15:22:22 +02:00
i3-companion: add support for BT devices without a class but with icon
This commit is contained in:
parent
59a4335ecd
commit
573b9c472c
1 changed files with 15 additions and 3 deletions
|
@ -815,7 +815,7 @@ async def bluetooth_status(i3, event, *args):
|
||||||
powered = True
|
powered = True
|
||||||
elif "org.bluez.Device1" in interfaces:
|
elif "org.bluez.Device1" in interfaces:
|
||||||
# We have a device!
|
# We have a device!
|
||||||
device = types.SimpleNamespace(major=0, minor=0, battery=None)
|
device = types.SimpleNamespace(major=0, minor=0, battery=None, icon=None)
|
||||||
interface = interfaces["org.bluez.Device1"]
|
interface = interfaces["org.bluez.Device1"]
|
||||||
if not interface["Connected"][1]:
|
if not interface["Connected"][1]:
|
||||||
continue
|
continue
|
||||||
|
@ -823,9 +823,16 @@ async def bluetooth_status(i3, event, *args):
|
||||||
device_class = interface["Class"][1]
|
device_class = interface["Class"][1]
|
||||||
device.major = (device_class & 0x1F00) >> 8
|
device.major = (device_class & 0x1F00) >> 8
|
||||||
device.minor = (device_class & 0xFC) >> 2
|
device.minor = (device_class & 0xFC) >> 2
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
device.battery = interfaces["org.bluez.Battery1"]["Percentage"][1]
|
device.battery = interfaces["org.bluez.Battery1"]["Percentage"][1]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
try:
|
||||||
|
device.icon = interface["Icon"][1]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
devices.append(device)
|
devices.append(device)
|
||||||
|
|
||||||
# Choose appropriate icons for output
|
# Choose appropriate icons for output
|
||||||
|
@ -861,8 +868,13 @@ async def bluetooth_status(i3, event, *args):
|
||||||
(lambda x: x & 0x20, "printer"),
|
(lambda x: x & 0x20, "printer"),
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
icon = classes.get((device.major, device.minor)) or classes.get(
|
bicons = {
|
||||||
device.major, "unknown"
|
"input-mouse": "mouse",
|
||||||
|
}
|
||||||
|
icon = (
|
||||||
|
bicons.get(device.icon)
|
||||||
|
or classes.get((device.major, device.minor))
|
||||||
|
or classes.get(device.major, "unknown")
|
||||||
)
|
)
|
||||||
if type(icon) is list:
|
if type(icon) is list:
|
||||||
for matcher, name in icon:
|
for matcher, name in icon:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue