Files
chandra/scripts/test-portal-dbus.sh
T
Claude 005e11e7bf
CI / test (push) Failing after 17s
Chrome follows the Dark mode switch: Chandra serves the portal's color-scheme
Chrome (and Firefox, Electron, GTK 4, Qt 6) read dark/light from xdg-desktop-portal's Settings
interface. With XDG_CURRENT_DESKTOP=chandra and no chandra-portals.conf, xdg-desktop-portal found
no Settings backend (gtk/gnome are UseIn=gnome, kde is UseIn=KDE) and exported no Settings
interface at all, so the gsettings color-scheme a790901 sets never reached Chrome.

- compositor/portal: the compositor is an org.freedesktop.impl.portal.Settings backend
  (org.freedesktop.impl.portal.desktop.chandra on the session bus): Read/ReadAll of
  org.freedesktop.appearance color-scheme (1 dark, 2 light), SettingChanged when the switch flips,
  version property, introspection. Login session only; the main loop wakes on its socket.
- compositor/network/dbus.mbt: serve calls (on_call, reply, reply_error), emit and receive
  signals, sender field, session bus address.
- session/chandra.portal + chandra-portals.conf, installed to /usr/share/xdg-desktop-portal by
  install.py: Settings from chandra first, then gtk/kde/gnome; other portals from gtk/kde/gnome.
- chandra-session restarts a running xdg-desktop-portal so it reads the config for this desktop.
- scripts/test-portal-dbus.sh: end to end behind the real xdg-desktop-portal on a private bus
  (ReadOne gives 1, flipping gives SettingChanged 2). docs/dark-mode.md: how to check it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hhkztRQM7vcSuHX4bB
2026-11-25 20:30:30 +00:00

35 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Run the portal package's end-to-end test: Chandra's Settings portal backend behind the real
# xdg-desktop-portal on a private session bus, configured by session/chandra.portal and
# session/chandra-portals.conf exactly as session/install.py installs them (apt: dbus
# xdg-desktop-portal). It checks what Chrome, Firefox, GTK 4 and Qt 6 see: ReadOne of
# org.freedesktop.appearance color-scheme, and SettingChanged when the Dark mode switch flips.
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"; cd "$ROOT"
XDP=""
for x in /usr/libexec/xdg-desktop-portal /usr/lib/xdg-desktop-portal; do
[ -x "$x" ] && XDP="$x" && break
done
[ -n "$XDP" ] || { echo "xdg-desktop-portal not found (apt install xdg-desktop-portal)" >&2; exit 1; }
tmp=$(mktemp -d)
mkdir -p "$tmp/portals" "$tmp/config" "$tmp/run"
cp session/chandra.portal "$tmp/portals/"
# The distro's backends too, as on a real system (chandra-portals.conf lists them after chandra).
cp /usr/share/xdg-desktop-portal/portals/*.portal "$tmp/portals/" 2>/dev/null || true
# With XDG_DESKTOP_PORTAL_DIR set, xdg-desktop-portal reads its config from there too.
cp session/chandra-portals.conf "$tmp/portals/"
export XDG_DESKTOP_PORTAL_DIR="$tmp/portals" XDG_CONFIG_HOME="$tmp/config" \
XDG_RUNTIME_DIR="$tmp/run" XDG_CURRENT_DESKTOP=chandra
addr_pid=$(dbus-daemon --session --fork --print-address=1 --print-pid=1)
export DBUS_SESSION_BUS_ADDRESS=$(echo "$addr_pid" | sed -n 1p)
DPID=$(echo "$addr_pid" | sed -n 2p)
trap 'kill ${XPID:-} "$DPID" 2>/dev/null || true; rm -rf "$tmp"' EXIT
dbus-update-activation-environment XDG_DESKTOP_PORTAL_DIR XDG_CONFIG_HOME XDG_RUNTIME_DIR \
XDG_CURRENT_DESKTOP
# Start xdg-desktop-portal before the backend is on the bus (the harder order: it must still find
# it once it appears); its log is printed if the test fails.
"$XDP" -v >"$tmp/xdp.log" 2>&1 &
XPID=$!
sleep 1
CHANDRA_PORTAL_E2E=1 moon test --target native --warn-list -a compositor/portal "$@" || { cat "$tmp/xdp.log"; exit 1; }