diff --git a/src/context.py b/src/context.py index b8c12b2..bb07f7d 100644 --- a/src/context.py +++ b/src/context.py @@ -44,19 +44,26 @@ class I3Provider(ContextProvider): def capture(self) -> Context: node = self._focused() - props = node.window_properties or {} + props = getattr(node, "window_properties", None) or {} return Context( window_id=node.id, - app_id=node.app_id or "", + app_id=getattr(node, "app_id", None) or "", klass=props.get("class") or "", instance=props.get("instance") or "", - title=node.name or "", + title=getattr(node, "name", None) or "", ) def is_same_focus(self, ctx: Context) -> bool: node = self._focused() return node.id == ctx.window_id + def focus_window(self, window_id: int) -> bool: + node = self.i3.get_tree().find_by_id(window_id) + if node is None: + return False + node.command("focus") + return True + def _match_text(val: str, needle: str | None) -> bool: if not needle: