This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Window Rules conditional on second monitor existing?

Tags: None
(comma "," separated)
Registered Member
Can I have Window Rules (System Settings > Workspace > Window Management > Window Rules) that are conditional on my laptop using an external monitor?

When I'm connected to an external monitor, I'd like several windows to be positioned on the laptop's monitor and pinned (visible on all desktops). When I'm only using the laptop's monitor, the windows should get default behavior. Is there a way to specify this?

I don't need anything to happen when I unplug or plug in the monitor; it's fine for existing windows to keep their last behavior.

Searching around, I cannot find a way inside of Window Rules to specify this. I didn't find anything that seemed relevant searching both here and with Google. I'm open to solutions that may involve "you'll need to write a shell script or program", but I have no idea where I might hook such a thing in, or if it's even possible. While "modify KWin" is something I could do, I'm hoping for something less invasive and time consuming.

I think I could solve the problem with polling, but that would be very inefficient, and unless I polled very frequently, would cause the window's behavior to change while I was trying to work with it.

My current solution is to always apply the "all desktops" rule, and just manually unpin the windows when I'm on my laptop only. I don't try to position it, as the position may be off screen without an external monitor.

If it matters, I'm using KDE 5.24.6 (at least plasmashell and kwin identify as such), from Kubuntu 22.04.1.


Who is online

Registered users: bartoloni, Bing [Bot], Google [Bot], Yahoo [Bot]