KWin Script to set Window Positions on Spawn in Plasma 6

Based on changes I’ve seen so far with modifications I’ve made to my own scripts, I think the following may work:

workspace.windowAdded.connect(window => {
    if (!window.normalWindow) return;
    area = workspace.clientArea(KWin.MaximizeArea, window);
    window.frameGeometry.x = area.x + area.width / 2 - window.width / 2;
    window.frameGeometry.y = area.y + area.height / 2 - window.height / 2;
});

The changes that I’m aware of here are:

  • workspace.clientAddedworkspace.windowAdded
  • window.geometrywindow.frameGeometry

Edit: I’ve just tested this and it seems to work, though it seems like it just centers windows.

If that’s what the script is meant to be doing, could you not go to System Settings and under Window ManagementWindow BehaviorAdvanced and set Window Placement to Centered?

Edit 2: Never mind, I see that still cascades windows in the center.

1 Like