Get primary display index from a KWin Script on Wayland

Hello!

I have a laptop and an external monitor. Previously, the laptop’s screen was the “primary” one, but I decided to rearrange them and set the external one as the new primary. After that, I noticed that this KWin script doesn’t work as expected anymore: it ignores the new primary screen setting.

I did some debugging, and it seems like on Wayland the primary display is not guaranteed to be with id 0. I haven’t found any means to identify the correct index with the KWin Script API: neither KWin::WorkspaceWrapper nor KWin::Options expose this information.

Is there a way to figure out the primary screen index from a KWin script on Wayland?

1 Like