How do I figure out the currently focused window in KDE wayland via shell (or other programming languages)

I’m trying to write an input remapper preset auto swapper, and while someone has already done it, that one only works for wl roots DEs like sway and hyprland, not KDE. I feel like this wouldn’t be an issue for steam games as Proton uses X11 still (I think)

I haven’t been able to find much info on how to do this in KDE, google’s AI results turn up this command wlr-desktop-shell-get-active-window however, this command doesn’t seem to work in the terminal. It could also be a Kwin command but I’m more familiar with Python than javascript.

Would really appreciate some help here. I’m not against using external tools. I’ve looked at kdotools but haven’t found any commands or variables I could use from that.