feat: Allow setting Bluetooth adapter alias to "Home Audio"
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
15
main.py
15
main.py
@@ -129,10 +129,25 @@ async def register_agent():
|
|||||||
except Exception as e2:
|
except Exception as e2:
|
||||||
logging.error(f'Failed to register agent again: {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 ---
|
# --- End Bluetooth ---
|
||||||
|
|
||||||
async def manage_bluetooth():
|
async def manage_bluetooth():
|
||||||
await register_agent()
|
await register_agent()
|
||||||
|
await set_adapter_alias("Home Audio")
|
||||||
# The agent will handle things, this task can just sleep
|
# The agent will handle things, this task can just sleep
|
||||||
while True:
|
while True:
|
||||||
await asyncio.sleep(3600)
|
await asyncio.sleep(3600)
|
||||||
|
|||||||
Reference in New Issue
Block a user