Here’s a working script I put together that does the same on Plasma 6, not sure if it’s the best way but works.
var keepAboveMaximized = new Array();
function setup(window) {
if (!window.normalWindow) return
console.error("setting up window", window.caption)
// here we connect our function to the maximizedChanged signal
// we need to know if our window is maximized so we also pass that
window.maximizedChanged.connect(() => {
toggleKeepAbove(window)
});
}
function toggleKeepAbove(window) {
// the size the window would have if it was maximized
const maximizedArea = workspace.clientArea(KWin.MaximizeArea, window)
// check if it's actually maximized
let maximized = window.height === maximizedArea.height && window.width === maximizedArea.width
console.error(window.caption, "maximized: ", maximized)
if (maximized) {
// if it had keep above add it to our keepAboveMaximized and remove keepAbove
if (window.keepAbove) {
console.log("saved and removed keepAbove")
keepAboveMaximized[keepAboveMaximized.length] = window;
window.keepAbove = false;
}
} else {
// no longer maximized
console.log("no longer maximized")
var found = keepAboveMaximized.indexOf(window);
// if the de-maximized window was previously set to keep above make it stay above again
if (found != -1) {
console.log("removed and restored keepAbove")
window.keepAbove = true;
keepAboveMaximized.splice(found, 1);
}
}
console.error("keep above now", window.keepAbove)
}
console.log("init")
// handle any new window
workspace.windowAdded.connect(setup)
Thank you, but you got me wrong. That’s the whole snippet, it is intentionally broken.
What I’m trying to show is that I can see the error messages just fine but I can’t see any print() outputs.
Depending on your distribution and graphics platform, it may also be necessary to have Plasma systemd boot enabled (this is the default since Plasma 5.25).