diff --git a/main.py b/main.py index 9bbd038..9fa6dca 100644 --- a/main.py +++ b/main.py @@ -129,10 +129,25 @@ async def register_agent(): except Exception as e2: logging.error(f'Failed to register agent again: {e2}') +async def set_adapter_alias(alias): + logging.info(f"Setting Bluetooth adapter alias to '{alias}'") + adapter_obj = await get_adapter() + if not adapter_obj: + logging.error('Bluetooth adapter not found, cannot set alias.') + return + + adapter_props = adapter_obj.get_interface('org.freedesktop.DBus.Properties') + try: + await adapter_props.call_set(ADAPTER_IFACE, 'Alias', Variant('s', alias)) + logging.info(f"Successfully set adapter alias to '{alias}'") + except Exception as e: + logging.error(f"Failed to set adapter alias: {e}") + # --- End Bluetooth --- async def manage_bluetooth(): await register_agent() + await set_adapter_alias("Home Audio") # The agent will handle things, this task can just sleep while True: await asyncio.sleep(3600)