diff --git a/svc/src/hudctrl/api.py b/svc/src/hudctrl/api.py index c41f986..fd27a08 100644 --- a/svc/src/hudctrl/api.py +++ b/svc/src/hudctrl/api.py @@ -71,7 +71,7 @@ def get_marionette(): @app.get('/screen/') async def list_screens(): - return {'screens': await svc.get_screens()} + return await svc.get_screens() @app.post( diff --git a/svc/src/hudctrl/hud.py b/svc/src/hudctrl/hud.py index 85e21c7..150bafb 100644 --- a/svc/src/hudctrl/hud.py +++ b/svc/src/hudctrl/hud.py @@ -2,7 +2,7 @@ import asyncio import json import logging from pathlib import Path -from typing import Dict, List, Optional +from typing import Dict, Optional import pydantic from aiomarionette import Marionette, WindowRect @@ -35,16 +35,16 @@ class HUDService: self.urls_file = Path('urls.json') - async def get_screens(self) -> List[HUDScreen]: + async def get_screens(self) -> Dict[str, HUDScreen]: assert self.marionette - screens = [] - for handle in await self.marionette.get_window_handles(): + screens = {} + for name, handle in self.windows.items(): await self.marionette.switch_to_window(handle) title = await self.marionette.get_title() url = await self.marionette.get_url() rect = await self.marionette.get_window_rect() - screens.append( - HUDScreen(handle=handle, title=title, url=url, dimensions=rect) + screens[name] = HUDScreen( + handle=handle, title=title, url=url, dimensions=rect ) return screens