diff --git a/bin/i3-companion b/bin/i3-companion index e4390a5..b96e73a 100755 --- a/bin/i3-companion +++ b/bin/i3-companion @@ -404,6 +404,37 @@ async def output_update(i3, event): output_update.running = asyncio.create_task(output_update_now()) +@on( + DBusSignal( + path="/org/bluez", + interface="org.freedesktop.DBus.Properties", + member="PropertiesChanged", + signature="sa{sv}as", + ) +) +async def bluetooth_notifications( + i3, event, path, interface, changed, invalid +): + """Display notifications related to Bluetooth state.""" + if interface != "org.bluez.Device1": + return + if not "Connected" in changed: + return + logger.info(changed["Connected"]) + peer = i3.system_bus["org.bluez"][path] + obd = await peer.get_async_interface(interface) + name = await obd.Name + icon = await obd.Icon + state = await obd.Connected + state = "connected" if state else "disconnected" + await notify( + i3, + app_icon=icon, + summary=name, + body=f"Bluetooth device {state}", + ) + + @on( DBusSignal( path="/", @@ -546,7 +577,7 @@ async def network_manager_status(i3, event, *args): if vpn: state = await nma.State if state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED: - status.append(icons['vpn']) + status.append(icons["vpn"]) status.append(await nma.Id) # Final status line