When I select a new window, I want to be able to consume a signal from the compositor / window / display server. However, KWin doesn’t appear to emit one.
However, this is such a fundamental feature that I don’t imagine that such a signal doesn’t exist. Consequently, is it merely not emitted via qdbus-qt6? If so, how does one consume it? (kdotool?)
Without any information about the window this would not be very valuable and information about the window, e.g. title, would leak information in an uncontrollable way.
Obviously KWin itself knows about the switch and its plugins and scripts can react to that.
You could likely “push” such an event via D-Bus from within a script
In my case, resourceClass and caption of the window are the things I care about, and therefore the arguments of the DBus method that consumes the message - but you can obviously choose your own.
@krake, thanks. That’s a shame, though, because doesn’t that require that I register a .desktop, main.js, and create a DBus signal, socket, or file to communicate outside of it with? For comparison, on Windows 24H2, I could call SetWinEventHook with C# code inline inside the PowerShell CLI, and subscribe to events from that.
@pg-tips, I commented this before I saw your comment. Thanks, too.
However, does it not also require a significant amount of preparation? The reason that I ask is because I’m trying to prepare a short script, to send to someone else, so the more that I can automate, the better. Certainly, I could touch each file to create a valid KWin Script, but that’s difficult. Can I somehow pipe this to KWin?
You can do this on your side and send your friend the .kwinscript file.
Install the script into Plasma, either through the System Settings app (“KWin Scripts” page, then click the “Install from File” button), or with these commands:
kpackagetool6 -t KWin/Script --install "/path/to/myscript.kwinscript"
qdbus-qt6 org.kde.KWin /Scripting unloadScript "myscript" # here, "myscript" is the Id of the KPlugin in metadata.json
qdbus-qt6 org.kde.KWin /Scripting start
Perhaps you could make a script containing these 3 commands and send that to your friend, if it’s easier than doing the install in the GUI.