3

Since Ubuntu 22.04 was released, this question is normal now.
I am writing a shell script which needs to get current active window name, so after searching for a tool for it, I decided to use xdotool.
But when I launch the terminal or settings, xdotool getwindowfocus getwindowname throws an error:
xdo_get_focused_window_sane failed (code=1)
xdo_focus_window reported an error
So how can I fix this error or how do I can get a current active window name?

AsKreY
  • 31

1 Answers1

2

xdotool only works for the Xorg display manager, not Wayland, and Wayland is default in Ubuntu 22.04. There is no equivalent way of selecting the focused window in Wayland. Your best bet if you need this functionality would be to switch to using Xorg and then the method you used to use will work.

If you want to stick with Wayland and are ok with digging rather deep to figure this out, you can use your window manager or compositor's method of getting open windows. This is not portable across WMs, and isn't possible in all situations. See this question about Gnome were it isn't really possible at all.

Esther
  • 3,600
  • 13
  • 29