fix: use D-Bus auto-activation for AT-SPI bus in isolated sessions#14
Open
isac322 wants to merge 1 commit into
Open
fix: use D-Bus auto-activation for AT-SPI bus in isolated sessions#14isac322 wants to merge 1 commit into
isac322 wants to merge 1 commit into
Conversation
The hardcoded `/usr/lib/at-spi-bus-launcher` path is only correct on Arch. Upstream at-spi2-core has migrated to `/usr/libexec/`, so on Fedora, Debian sid, Ubuntu 24.04+, and Flatpak runtimes the AT-SPI bus never starts and every AT-SPI tool (accessibility_tree, find_ui_elements, wait_for_element, list_windows, focus_window) fails with "Couldn't connect to accessibility bus". Replace the manual launcher invocation with a D-Bus auto-activation trigger (`gdbus call org.a11y.Bus.GetAddress`). dbus-daemon resolves the service file and execs the launcher at whatever path the current distro's package installed it to, so kwin-mcp no longer encodes any binary path. at-spi2-registryd is auto-activated on first access by the same mechanism, so no manual bootstrap is needed. Also drop AT_SPI_PID from the cleanup trap — auto-activated processes are torn down when dbus-run-session closes the session bus. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
61b7280 to
0b2de17
Compare
📝 Docs & SEO ReviewSource files changed in this PR: Consistency check results:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the hardcoded
/usr/lib/at-spi-bus-launcherpath with D-Bus auto-activation so thataccessibility_tree,find_ui_elements,wait_for_element,list_windows, andfocus_windowwork in isolated virtual sessions on all distros — not just Arch.Problem
_build_wrapper_script()insession.py:346currently launches the AT-SPI bus by execing a hardcoded path:/usr/lib/at-spi-bus-launcher --launch-immediately &This path is only correct on Arch/Manjaro. Upstream
at-spi2-corehas migrated to/usr/libexec/, so on the following platforms the AT-SPI bus is never started:/usr/libexec/at-spi-bus-launcher)noble) and later (/usr/libexec/at-spi-bus-launcher)/app/libexec/at-spi-bus-launcher)With no a11y bus, every subsequent
_run_atspi()call crashes with "Couldn't connect to accessibility bus". The bug had been invisible because development happens on Arch, which still uses/usr/lib/.Fix — delegate path resolution to D-Bus auto-activation
Don't try to resolve the binary path in kwin-mcp. Let
dbus-daemondo it:gdbus call --session \ --dest=org.a11y.Bus \ --object-path=/org/a11y/bus \ --method=org.a11y.Bus.GetAddress >/dev/null 2>&1 || truedbus-daemonreads/usr/share/dbus-1/services/org.a11y.Bus.serviceand execs the launcher at whatever path the current distro's package actually installed it to. Path resolution becomes the packaging layer's responsibility, which is how AT-SPI is designed to bootstrap.The registry daemon (
at-spi2-registryd) also does not need to be started manually — it is auto-activated on first access to the a11y bus through the same mechanism.Incidental cleanup
AT_SPI_PIDfrom the cleanup trap. Auto-activated processes are torn down whendbus-run-sessioncloses the session bus, so no explicitkillis needed.sleep 0.2→sleep 0.3.gdbus callreturns as soon as the bus address reply arrives, which is slightly earlier than full launcher initialization.Relationship to #8
This PR is an alternative to #8, opened by @davidselassie after hitting the Fedora failure. #8 parses the
Exec=line from the service file withsedand starts the launcher and registryd manually. The auto-activation approach here removes the need for theIsEnabledproperty flip, the--use-gnome-sessionworkaround, and the manual registryd bootstrap —dbus-daemonpicks all of that up from the same service files.Testing
accessibility_treeshould return a real widget tree, not"(no accessible applications found)":Verified locally on Arch (
/usr/lib/). Cross-distro verification (Fedora in particular) is welcome.Checklist
uv run ruff check .passesuv run ruff format --check .passesuv run ty checkpasses🤖 Generated with Claude Code