Harden i3 context capture
This commit is contained in:
parent
0e79edfa20
commit
328dcec458
1 changed files with 10 additions and 3 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue