Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
ci(linux): KDE Plasma desktop for the Linux harness (#3301)
Richie McIlroye8db1fe537c8
diff --git a/scripts/linux-desktop-harness/README.md b/scripts/linux-desktop-harness/README.mdindex 31faf33ec..be35930e3 100644--- a/scripts/linux-desktop-harness/README.md+++ b/scripts/linux-desktop-harness/README.md@@ -9,6 +9,7 @@ runs it on every pull request that touches the desktop app.| --- | --- | --- || `gnome` | Ubuntu 26.04, GNOME 50 headless, AppIndicator, xdg-desktop-portal 1.21+ | Ubuntu users: shortcut approval dialog, `ShortcutsChanged`, Share Screen dialog || `hyprland` | Arch, Hyprland on vkms, waybar tray, xdg-desktop-portal-hyprland | Omarchy users: the portal refuses host apps ("An app id is required"), tray Stop control, no configure after a remap |+| `kde` | Arch, KWin 6 on its virtual backend, plasmashell tray, xdg-desktop-portal-kde | Plasma users: the screen-share dialog (its screens are buttons), the tray Stop control with `LAUNCH=dock`. Needs a DRM render node (`modprobe vgem`): KWin streams screens only when it composites with OpenGL, so it does not run on CI's runners. KWin's virtual backend takes no injected keys, so a shell launch's Stop shortcut is approved (`APPROVE_SHORTCUT_AFTER`) but not pressed || `sway`, `niri` | Arch on vkms | Exploration only: their portals need a render node vkms does not have, and niri refuses software rendering |Each run (`run-desktop.sh <desktop> <package> <out-dir> [KEY=VALUE...]`):diff --git a/scripts/linux-desktop-harness/atspi-press.py b/scripts/linux-desktop-harness/atspi-press.pyindex 86877a9fc..4d96529da 100644--- a/scripts/linux-desktop-harness/atspi-press.py+++ b/scripts/linux-desktop-harness/atspi-press.py@@ -44,7 +44,11 @@ def find(scope_re, button_re):name = node.get_name() or ""except Exception:continue- if role in (Atspi.Role.PUSH_BUTTON, Atspi.Role.TOGGLE_BUTTON) and button_re.search(name):+ # Qt reports its buttons with the plain "button" role.+ is_button = role in (Atspi.Role.PUSH_BUTTON, Atspi.Role.TOGGLE_BUTTON) or (+ node.get_role_name() == "button"+ )+ if is_button and button_re.search(name):return nodereturn Nonediff --git a/scripts/linux-desktop-harness/kde-up.sh b/scripts/linux-desktop-harness/kde-up.shnew file mode 100755index 000000000..172fa2c85--- /dev/null+++ b/scripts/linux-desktop-harness/kde-up.sh@@ -0,0 +1,59 @@+#!/usr/bin/env bash+# Runs as the test user inside the systemd KDE container: KWin on its virtual+# backend at 1920x1080 with plasmashell (the tray host) and the KDE portal, in+# software. Exports the session to the user bus and systemd manager.+set -euo pipefail+export XDG_RUNTIME_DIR=/run/user/$(id -u)+export DBUS_SESSION_BUS_ADDRESS=unix:path=$XDG_RUNTIME_DIR/bus+out=${HARNESS_OUT:-/out}+mkdir -p "$out" "$HOME/.config/systemd/user"+session=(XDG_SESSION_TYPE=wayland XDG_CURRENT_DESKTOP=KDE XDG_SESSION_DESKTOP=KDE KDE_FULL_SESSION=true+ KDE_SESSION_VERSION=6 LIBGL_ALWAYS_SOFTWARE=1 QT_QPA_PLATFORM=wayland QT_LINUX_ACCESSIBILITY_ALWAYS_ON=1+ KWIN_COMPOSE=O2)+systemctl --user set-environment "${session[@]}"+# The KDE portal backend, like GNOME's, waits for graphical-session.target.+cat >"$HOME/.config/systemd/user/cap-harness-session.target" <<'UNIT'+[Unit]+Description=Cap harness graphical session+BindsTo=graphical-session.target+Before=graphical-session.target+UNIT+systemctl --user daemon-reload+systemctl --user start cap-harness-session.target++# KWin streams screens only when it composites with OpenGL, which its virtual+# backend does only on a DRM render node (load vgem on a host without a GPU).+ls /dev/dri/renderD* >/dev/null 2>&1 ||+ { echo "kde-up: no DRM render node; run 'modprobe vgem' on the host" >&2; exit 1; }+systemctl --user reset-failed kwin-headless.service >/dev/null 2>&1 || true+# KWin brings its own Qt platform; the session's is for the apps it hosts.+kwin_env=()+for variable in "${session[@]}"; do+ [[ $variable == QT_QPA_PLATFORM=* ]] || kwin_env+=("$variable")+done+systemd-run --user --unit=kwin-headless --collect \+ -p StandardOutput=file:"$out/compositor.log" -p StandardError=inherit \+ env "${kwin_env[@]}" kwin_wayland --virtual --width 1920 --height 1080 --no-lockscreen --socket wayland-0+for _ in $(seq 600); do+ [[ -S "$XDG_RUNTIME_DIR/wayland-0" ]] && break+ sleep 0.1+done+[[ -S "$XDG_RUNTIME_DIR/wayland-0" ]] || { echo "kde-up: no Wayland socket" >&2; exit 1; }+export WAYLAND_DISPLAY=wayland-0 "${session[@]}"+systemctl --user set-environment WAYLAND_DISPLAY=wayland-0+dbus-update-activation-environment --systemd WAYLAND_DISPLAY "${session[@]%%=*}"++systemd-run --user --unit=plasmashell --collect \+ -p StandardOutput=file:"$out/plasmashell.log" -p StandardError=inherit plasmashell+tray=no+for _ in $(seq 300); do+ if gdbus call --session --dest org.kde.StatusNotifierWatcher --object-path /StatusNotifierWatcher \+ --method org.freedesktop.DBus.Properties.Get org.kde.StatusNotifierWatcher \+ IsStatusNotifierHostRegistered 2>/dev/null | grep -q "<true>"; then+ tray=yes+ break+ fi+ sleep 0.1+done+[[ $tray == yes ]] || { echo "kde-up: plasmashell registered no tray host" >&2; exit 1; }+echo "kde-up: $(kwin_wayland --version 2>/dev/null) on wayland-0"diff --git a/scripts/linux-desktop-harness/kde.Dockerfile b/scripts/linux-desktop-harness/kde.Dockerfilenew file mode 100644index 000000000..6c7d2a40a--- /dev/null+++ b/scripts/linux-desktop-harness/kde.Dockerfile@@ -0,0 +1,18 @@+# Arch Linux with KDE Plasma's compositor, shell and portal: KWin on its+# virtual backend (no display device), plasmashell as the tray host and+# kglobalacceld for global shortcuts, rendering with llvmpipe. systemd is PID 1+# for the same reasons as the other images.+FROM archlinux:latest+RUN pacman -Syu --noconfirm --needed \+ systemd dbus kwin plasma-workspace plasma-desktop kglobalacceld xdg-desktop-portal xdg-desktop-portal-kde \+ breeze qt6-wayland pipewire wireplumber pipewire-pulse mesa vulkan-swrast vulkan-icd-loader \+ at-spi2-core python python-gobject glib2 procps-ng psmisc fuse2 ttf-dejavu wl-clipboard \+ && pacman -Scc --noconfirm+RUN useradd -m -u 1001 tester \+ && mkdir -p /var/lib/systemd/linger && touch /var/lib/systemd/linger/tester \+ && systemctl mask systemd-binfmt.service proc-sys-fs-binfmt_misc.automount \+ proc-sys-fs-binfmt_misc.mount systemd-udevd.service systemd-udevd-kernel.socket \+ systemd-udevd-control.socket [email protected] console-getty.service \+ systemd-firstboot.service systemd-homed.service+STOPSIGNAL SIGRTMIN+3+CMD ["/sbin/init"]diff --git a/scripts/linux-desktop-harness/run-desktop.sh b/scripts/linux-desktop-harness/run-desktop.shindex 8e4468487..34f4f5177 100644--- a/scripts/linux-desktop-harness/run-desktop.sh+++ b/scripts/linux-desktop-harness/run-desktop.sh@@ -1,6 +1,6 @@#!/usr/bin/env bash# Host side: one fresh desktop container, one Cap package, one scenario.-# Usage: run-desktop.sh <gnome|hyprland|niri|sway> <package.deb|.AppImage|any file with DEV_BIN> <out-dir> [ENV=VALUE...]+# Usage: run-desktop.sh <gnome|kde|hyprland|niri|sway> <package.deb|.AppImage|any file with DEV_BIN> <out-dir> [ENV=VALUE...]set -euo pipefailhere=$(cd "$(dirname "$0")" && pwd)desktop=$1@@ -14,6 +14,7 @@ case "$desktop" in# on the vgem/vkms faux devices this harness renders with; real GPUs are not# affected, so the harness (not Cap) turns that layer off.hyprland|niri|sway) image=cap-harness-arch dockerfile=arch.Dockerfile up=arch-up.sh extra_env=(-e VK_LOADER_LAYERS_DISABLE=VK_LAYER_MESA_device_select) ;;+ kde) image=cap-harness-kde dockerfile=kde.Dockerfile up=kde-up.sh ;;*) echo "unknown desktop $desktop" >&2; exit 2 ;;esacname=cap-$desktop-$$diff --git a/scripts/linux-desktop-harness/scenario-start-stop.sh b/scripts/linux-desktop-harness/scenario-start-stop.shindex 38435beb3..1335d3d37 100644--- a/scripts/linux-desktop-harness/scenario-start-stop.sh+++ b/scripts/linux-desktop-harness/scenario-start-stop.sh@@ -65,7 +65,11 @@ use_control() {fi;;shortcut) python3 "$here/mutter-keys.py" Control_L+Shift_L+F9 >>"$out/actions.log" 2>&1 ;;- approve) python3 "$here/atspi-press.py" "${2:-Add Keyboard Shortcuts}" "${3:-^Add$}" 20 >>"$out/actions.log" 2>&1 ;;+ approve)+ local scope="Add Keyboard Shortcuts" button="^Add$"+ [[ ${DESKTOP:-gnome} == kde ]] && scope="xdg-desktop-portal-kde" button="^OK$"+ python3 "$here/atspi-press.py" "${2:-$scope}" "${3:-$button}" 20 >>"$out/actions.log" 2>&1+ ;;# No tray and no shortcut: Cap records with its controls on screen. Find# that window, then click the red Stop button in it with the pointer.visible)@@ -122,9 +126,13 @@ attempt() {result "attempt${n}_control" "$control"[[ $control == tray || $control == shortcut ]] && use_control "$control"# The screen-share dialog: a person picks the screen and presses Share.- # GNOME's portal draws this dialog on GNOME, and on niri, which uses it.+ # GNOME's portal draws this dialog on GNOME, and on niri, which uses it;+ # KDE's portal on Plasma.if [[ ${DESKTOP:-gnome} == gnome || $DESKTOP == niri ]] && ! wait_log "recording started" 4 "$started_before"; thenuse_control approve "Share Screen|xdg-desktop-portal-gnome" "^Share$"+ elif [[ $DESKTOP == kde ]] && ! wait_log "recording started" 4 "$started_before"; then+ # KDE's dialog lists each screen as a button that shares it.+ use_control approve "xdg-desktop-portal-kde" "^Virtual-0$"fiif wait_log "recording started" 30 "$started_before"; thenresult "attempt${n}_started" yes