How to get focused window title in a python or bash script on wayland

This is not an easy information to obtain in Wayland.
You would need to implement client support for some custom wayland protocol (src/protocols/plasma-window-management.xml · master · Libraries / Plasma Wayland Protocols · GitLab src/protocols/idle.xml · master · Libraries / Plasma Wayland Protocols · GitLab), which are not implemented in any library (you could follow some examples in taskmanager implementation or kwayland).
Only the task manager has access to this normally.

In X11, there is no restriction, you should be able to find existing ways.

1 Like