feat: add KDE Plasma 6 window positioning handler#864
Open
SemmerSky wants to merge 1 commit into
Open
Conversation
The existing kscript handler stopped working in Plasma 5.71 due to API changes. On Plasma 6 Wayland, NormCap overlay windows pile up on the primary monitor instead of spanning all screens correctly. New kwin6 handler using the updated Plasma 6 JavaScript API: - workspace.windowList() (or workspace.windows as fallback property) - window.frameGeometry = Qt.rect(...) for positioning Implementation details: - Uses jeepney for D-Bus calls (consistent with ADR 006) - json.dumps() for the window title in the JS snippet — prevents injection if the title contains quotes or backslashes - Unloads any leftover script before loading fresh (fixes repeated captures hanging in rare cases) - Cleans up temp .js file in a finally block on all code paths - @functools.cache on _get_plasma_major_version() to avoid repeated plasmashell subprocess calls Includes 13 tests covering compatibility checks, JS generation, special character escaping, and D-Bus error handling. Tested on Fedora 44, KDE Plasma 6.3, Wayland, 3-monitor setup. Co-Authored-By: Claude Sonnet 4.6 <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.
Problem
The existing
kscripthandler stopped working in Plasma 5.71 due to API changes (workspace.clientList()andclient.geometrywere removed). On Plasma 6 Wayland with multiple monitors, NormCap overlay windows pile up on the primary monitor instead of spanning all screens — making it practically unusable in multi-monitor setups.Solution
New
kwin6handler using the updated Plasma 6 JavaScript API:workspace.windowList()(withworkspace.windowsas a fallback property for minor-version differences)window.frameGeometry = Qt.rect(x, y, w, h)for positioning (stable since Plasma 6.0)The handler is selected automatically on KDE Plasma 6+ and falls back gracefully to
kscripton Plasma 5.Implementation notes
json.dumps()for the window title in the JS snippet correctly escapes quotes, backslashes, and newlines in window titles.jsfile in afinallyblock on all code paths@functools.cacheon_get_plasma_major_version()to avoid repeatedplasmashellsubprocess callsTests
13 tests covering:
is_compatible()for KDE/non-KDE, Plasma 5/6, unknown versionis_installed()returning bool without raisingTesting
Tested on Fedora 44, KDE Plasma 6.3, Wayland, 3-monitor setup. All 3 monitors are positioned correctly.