How can I get current active screen (a screen with mouse) in KDE wayland?
20:38 19 Jun 2022

I want to be able to detect active screen in KDE from my python script. Previously I used Xlib and was looking for the screen with mouse like so:

from Xlib import display
def mousepos():
    data = display.Display().screen().root.query_pointer()._data
    return data["root_x"], data["root_y"]

current_pos = mousepos()
x_pos = current_pos[0]
y_pos = current_pos[1]

names_handling_y = []
names_handling_x = []
...
    if x_pos >= output["pos"]["x"] and x_pos <= output["pos"]["x"] + output["size"]["width"]:
        names_handling_x.append(output["name"])
    if y_pos >= output["pos"]["y"] and y_pos <= output["pos"]["y"] + output["size"]["height"]:
        names_handling_y.append(output["name"])
...
for name in names_handling_x:
    if name in names_handling_y:
        target_output = name

But how can I do similar thing when using Wayland?

python x11 kde-plasma wayland