Repository navigation
Conversation
On Wayland, X11 calls only see XWayland windows, and on KDE the current Wayland code path calls org.gnome.Shell and fails. This adds a backend that loads small KWin scripts through KWin's D-Bus scripting interface; the script reads or changes the requested windows and sends the result back with callDBus(). It works for every window, including native Wayland ones. - New _pywinctl_linux_kwin module (KWinWindow + module functions) - Selected automatically on Wayland + KDE + KDE_SESSION_VERSION >= 6; PYWINCTL_LINUX_BACKEND=x11|kwin forces a backend - New Linux-only dependency: jeepney (pure Python D-Bus) - tests/test_kwin_backend.py: backend selection + live tests on KWin Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Avasam
reviewed
Nov 13, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Adds a KDE Plasma 6 Wayland backend. Today, on a KDE Wayland session, the Linux backend goes down the Wayland path, calls
org.gnome.Shell.Evaland fails (getAllTitles()raisesCalledProcessErroron Fedora 44 / Plasma 6.8). X11 calls through XWayland only see XWayland windows, so native Wayland apps (Dolphin, KCalc, Firefox, ...) are invisible.On KDE the compositor can be scripted. The new backend loads a small KWin script through KWin's D-Bus scripting interface (
org.kde.kwin.Scripting.loadScript). The script reads or changes the requested window(s) and sends the result back withcallDBus()to a temporary D-Bus method we listen on. Then the script is unloaded. This works for all windows, including native Wayland ones, and each call takes a few ms.Changes
src/pywinctl/_pywinctl_linux_kwin.py: newKWinWindow(BaseWindow)and the module-level functions, mirroring_pywinctl_linux.py. Window handles are KWin internal ids (UUID strings)._main.py: on Linux, picks the KWin backend whenXDG_SESSION_TYPE=wayland,XDG_CURRENT_DESKTOPcontainsKDEandKDE_SESSION_VERSION >= 6. Everything else (X11, GNOME, Plasma 5) keeps the current backend.PYWINCTL_LINUX_BACKEND=x11|kwinforces one backend.jeepney(sys_platform == 'linux'). It is pure Python with no dependencies (a ~49 KB wheel), and it is only imported when the KWin backend is actually used. If it is missing, a clearKWinErrorexplains how to install it. Environment markers can't detect the desktop, so it's installed on all Linux systems. Shelling out togdbus(as the GNOME path does) isn't enough here, because we need to receive a D-Bus call from KWin.uv.lock: only addsjeepney(+11 lines, lock format unchanged).mypy.ini:follow_untyped_importsforjeepney, like theobjcentries.tests/test_kwin_backend.py: a plain script, liketest_pywinctl.py. It tests backend selection anywhere on Linux, and runs live tests (with akittywindow) only inside a Plasma 6 Wayland session.Wayland limitations (documented)
hide()minimizes the window.sendBehind()keeps the window below the others; it can't go behind the desktop.acceptInput()andsetParent()aren't supported.wait=Trueto confirm it.Testing
tests/test_pywinctl.py'sbasic_test()passes in full against a kitty window, including the watchdog callbacks.tests/test_kwin_backend.pypasses.jeepney0.8.0 and 0.9.0.testsjob in an Ubuntu 24.04 container (Xvfb + openbox + gedit,uv sync --locked). The result is identical before and after this change.mypy ., Python 3.9 and 3.14,--platformlinux/win32/darwin): same results asmaster.py3-none-any. Resolving dependencies for Windows/macOS doesn't pulljeepney.sys.platform == "linux"branch) and a real Plasma 5 session (only the selection logic was tested).🤖 Generated with Claude Code