Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Segfault on Python 3.14 caused by missing `argtypes` on variadic `ei_seat_bind_capabilities` ctypes call
- `accessibility_tree`, `find_ui_elements`, `wait_for_element`, `list_windows`, and `focus_window` now work in isolated virtual sessions on Fedora, Debian, Ubuntu, and any other distro that installs the AT-SPI bus launcher outside `/usr/lib` (e.g. `/usr/libexec`). Instead of executing a hardcoded path, the AT-SPI bus is now brought up via D-Bus auto-activation (`gdbus call org.a11y.Bus.GetAddress`), which defers binary-path resolution to `dbus-daemon` and the distro-provided service file. The registry daemon is auto-activated transparently when apps first touch the a11y bus, so no manual bootstrap is required. Thanks to @davidselassie for reporting the Fedora failure in [#8](https://github.com/isac322/kwin-mcp/pull/8).

## [0.7.0] - 2026-03-29

Expand Down
31 changes: 22 additions & 9 deletions src/kwin_mcp/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,19 +333,32 @@ def _build_wrapper_script(self, config: SessionConfig) -> str:
return f"""\
echo "DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS"

# Ensure all child processes are cleaned up on exit
# Ensure all child processes are cleaned up on exit.
# The AT-SPI bus launcher and registryd are started via D-Bus
# auto-activation below; they are terminated automatically when our
# isolated session bus exits (dbus-run-session tears the bus down on
# parent exit), so we only need to track KWin explicitly here.
cleanup() {{
kill $KWIN_PID $AT_SPI_PID 2>/dev/null
wait $KWIN_PID $AT_SPI_PID 2>/dev/null
kill $KWIN_PID 2>/dev/null
wait $KWIN_PID 2>/dev/null
}}
trap cleanup EXIT TERM INT HUP

# Start the AT-SPI accessibility bus.
# ATSPI_DBUS_IMPLEMENTATION is set in _build_env() to force dbus-daemon
# instead of dbus-broker (which reuses the host's AT-SPI bus).
/usr/lib/at-spi-bus-launcher --launch-immediately &
AT_SPI_PID=$!
sleep 0.2
# Bring up the AT-SPI accessibility bus via D-Bus auto-activation.
# Calling org.a11y.Bus.GetAddress makes dbus-daemon resolve the
# service file (/usr/share/dbus-1/services/org.a11y.Bus.service) and
# exec the launcher at whatever path the current distro uses — Arch
# /usr/lib, Fedora/Debian/Ubuntu /usr/libexec, Flatpak /app/libexec,
# etc. Hardcoding a path breaks on everything except Arch.
# ATSPI_DBUS_IMPLEMENTATION=dbus-daemon (set in _build_env) prevents
# dbus-broker from sharing the host's a11y bus.
# The registryd comes up on its own when apps first touch the a11y
# bus, so no manual bootstrap is needed here.
gdbus call --session \\
--dest=org.a11y.Bus \\
--object-path=/org/a11y/bus \\
--method=org.a11y.Bus.GetAddress >/dev/null 2>&1 || true
sleep 0.3

# Pre-set D-Bus activation environment BEFORE starting KWin.
# When KWin triggers portal auto-activation, portal-kde will get
Expand Down