Does KWin emit a signal (via DBus) on window change?

I use a Javascript KWin script to do just that:

const SERVICE_NAME = 'com.example.blah';
const OBJECT_PATH = '/com/example/blah';
const INTERFACE_NAME = 'com.example.blah';

workspace.windowActivated.connect(function(client){
    if (client) {
        callDBus(
            SERVICE_NAME,
            OBJECT_PATH,
            INTERFACE_NAME,
            'ActiveWindowChanged',
            client.resourceClass,
            client.caption
        );
    }
});

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.

You can just use dbus-monitor to listen if you like - see Execute a command from a kwin script - #4 by pg-tips

2 Likes