summaryrefslogtreecommitdiff
path: root/bus
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2021-05-19 15:08:42 +0200
committerBenjamin Berg <bberg@redhat.com>2021-05-19 15:14:26 +0200
commit8d514cc1b8456224fa687bc0e32d26c3b4b994c0 (patch)
tree20a73f33901cdd75934416eac07ff52d039dafd9 /bus
parent1a7d59f174a66d2b46a7774c1f09154a94ea151c (diff)
downloadat-spi2-core-8d514cc1b8456224fa687bc0e32d26c3b4b994c0.tar.gz
bus: Set X root property when Xwayland starts on-demand
On wayland, the X11 server may not always be running so that at-spi-bus-launcher cannot set it when it is starting. This is usually not a big problem, as applications can retrieve the a11y bus address by querying the session bus. Unfortunately, there may be exceptions such as applications that are run as a different user. We can easily solve this problem by setting the X11 root property when the Xwayland server is started. To do so, install a simple script to /etc/xdg/Xwayland-session.d/ that queries the session bus and sets the root property. This script is only needed when Xwayland is started on-demand, which can only happen on systemd enabled sessions. However, it is always safe to install, and there will be no severe side effects should the script be running needlessly or failing. Closes: #34
Diffstat (limited to 'bus')
-rwxr-xr-xbus/00-at-spi10
-rw-r--r--bus/meson.build8
2 files changed, 18 insertions, 0 deletions
diff --git a/bus/00-at-spi b/bus/00-at-spi
new file mode 100755
index 00000000..dc3bb605
--- /dev/null
+++ b/bus/00-at-spi
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# Copy a11y bus address from the DBus session bus to the X11 root property.
+# This is useful when Xwayland is started on demand and if the user has an
+# application with X11 access that does not have access to the session bus.
+
+ADDR="$( busctl call --user org.a11y.Bus /org/a11y/bus org.a11y.Bus GetAddress )" || exit 0
+ADDR="$( echo $ADDR | sed 's/s "\(.*\)"/\1/' )" || exit 0
+
+exec xprop -root -format AT_SPI_BUS 8s -set AT_SPI_BUS "$ADDR"
diff --git a/bus/meson.build b/bus/meson.build
index f6c32c99..3504fb31 100644
--- a/bus/meson.build
+++ b/bus/meson.build
@@ -6,6 +6,7 @@ accessibility_conf.set('DATADIR', atspi_datadir)
busconfig_dir = join_paths(atspi_datadir, 'defaults/at-spi2')
session_dir = join_paths(atspi_sysconfdir, 'xdg/autostart')
+xwayland_session_dir = join_paths(atspi_sysconfdir, 'xdg/Xwayland-session.d')
configure_file(input: 'accessibility.conf.in',
output: 'accessibility.conf',
@@ -27,6 +28,13 @@ configure_file(input: 'at-spi-dbus-bus.service.in',
configuration: libexec_conf,
install_dir: systemd_user_dir)
+if x11_dep.found()
+ # Note: It is safe to always install it. However, we only need this on
+ # systemd enabled machines where Xwayland may be started on-demand.
+ install_data('00-at-spi',
+ install_dir: xwayland_session_dir)
+endif
+
launcher_args = [
'-DSYSCONFDIR="@0@"'.format(atspi_sysconfdir),
'-DDATADIR="@0@"'.format(atspi_datadir),