There are applications which are more or less a mess for a window manager. For example The GIMP opens quite a lot of windows and you want to have all of those windows visible. In general you don’t want to have any other window on the same desktop

The solution to that is to move GIMP on it’s own desktop. But how? We can use static window rules to get this working, but what if there are already windows on that desktop? The perfect solution to that would be to have a desktop which gets created when you open GIMP and gets removed again when GIMP closes.

This was so far not yet possible without manual interaction. But with todays additions to KWin scripting this became possible. Here I present a KWin script which does exactly that:

workspace.clientAdded.connect(function(client) { if (client.resourceClass == "gimp-2.6" && client.windowRole == "gimp-image-window") { // create a new workspace for the Gimp image window (kind of the main window) // switch to the new desktop and send the gimp window to it workspace.desktops = workspace.desktops+1; workspace.currentDesktop = workspace.desktops; client.desktop = workspace.currentDesktop; } else if (client.resourceClass == "gimp-2.6") { // send all other gimp windows to the current desktop client.desktop = workspace.currentDesktop; } }); workspace.clientRemoved.connect(function(client) { if (client.resourceClass == "gimp-2.6" && client.windowRole == "gimp-image-window") { // when closing the gimp window let's remove the last desktop workspace.desktops = workspace.desktops-1; } });

I should really start to publish the quite useful example scripts I write to test the scripting functionality on places like kde-apps 🙂 The API for 4.9 is documented on Techbase