Closed 1player closed 9 months ago
Ah, looks like KDE has its own Wayland protocol to do that... https://wayland.app/protocols/kde-plasma-window-management
If I was more comfortable with C++ I would attempt to write a PR, but for now I leave it to more experienced hands.
I've spent a few minutes trying to add support for that protocol, but I do not see it exported on a live KDE system. Perhaps because it says it can only be bound to one client at a time.
I noticed there's a org.kde.KWin.queryWindowInfo
DBus method:
Which returns all the information we need in the caption
and resourceClass
attributes (title and app_id respectively). Sadly this is only for interactive use: you need to manually click a window to get its information back. There is a getWindowInfo
method that requires a window UUID parameter, but I don't see any way of listing all windows in the first place. Why is this so needlessly complex...
I reckon the viable approach is to replicate what you're doing for GNOME, and create a custom KWin script that interacts with the Keymapper DBus server. Determining the attributes of the active window from there should be easy enough.
See also:
I'm not sure when I'll have the time to work on that, but this should be enough information to get started if anyone wants to have a crack at it.
Hi, thank you very much for your contributions! This was already on my TODO list.
I stumbled over this kwin-script.js from the xremap project.
For keymapper it likely will be:
workspace.clientActivated.connect(function(client){
callDBus(
"com.github.houmain.Keymapper",
"/com/github/houmain/Keymapper",
"com.github.houmain.Keymapper",
"WindowFocus",
"caption" in client ? client.caption : "",
"resourceClass" in client ? client.resourceClass : ""
);
});
But there is also some rust code, so I do not know if putting the .js somewhere is enough... From what I can see here a script and a metadata.json should be enough. Maybe you could figure that out?
I confirmed in plasma-interactiveconsole
that this script works. The extra code is there to load the script into KWin, but another option is packaging the script per https://develop.kde.org/docs/plasma/kwin/ into a regular script and installing it from system settings.
Hi Albert, thanks for trying it out! It is now in the 3.3.0 release.
The focused window is GNU Emacs with class
emacs
. Wayland support is compiled correctly, as shown by cmake.Tested with the latest code from master.