4

I am currently having a very simply problem, that I cannot for the life of me figure out. The --window function of xdotool does not work.

I should be able to open two terminal windows, get the windowID of one of them and run

xdotool key --window "WindowID" x 

But nothing happens.

If I type in a non-existing windowID, I get a BadWindowID error, so it finds the window.

If I type in the windowID of the same terminal window I type the command into, nothing happens.

I can also do a simple sleep 5; xdotool key x and switch to another terminal window, which correctly results in a keystroke in the newly selected terminal window, but that's not the point.

My only (functional) workaround currently is to switch between windows, execute the keystroke and switch back, thus circumventing the --window function, but it's making my eyes bleed.

tmp=$(xdotool getactivewindow); xdotool windowactivate --sync $(xdotool search --name "WINDOWNAME") key x; xdotool windowactivate $tmp 

I have tried running it as a bash script, as root, I've tried using getting the windowID as a variable in the same line and getting it in separate script. My only other idea now is to update my distribution assuming there is some fault in my window manager.

I am running Mint 20, Xfce 64, x11, xfce4-terminal

6
  • Explaining your objectives, may result in a different and better solution. Commented Mar 24, 2023 at 21:52
  • Which terminal emulator are you testing this with? Some ignore such events (as mentioned in the SENDEVENT NOTES section of the man page). How did you determine the window ID? Commented Mar 24, 2023 at 22:55
  • @ctrl-alt-delor My final objective is to set up little bash xdotool scripts to send keystrokes to a wine window on a separate desktop (same x session). I have done this before on another mint installation using this method. Commented Mar 25, 2023 at 1:54
  • @steeldriver ps -o 'cmd=' -p $(ps -o 'ppid=' -p $$) returns xfce4-terminal. So I assume that is correct. As stated above I did a sleep 5; xdotool key x command and switched terminal windows manually, which works fine. I can switch windows with windowID and run key commands. I determined the window ID by running getactivewindow, but I have also done searches by name etc, with xdotool, and gotten the same results. Commented Mar 25, 2023 at 1:57
  • Put all information in the question. Comments can come and go, and are not always read. Commented Mar 27, 2023 at 17:55

1 Answer 1

4

(Not enough rep to comment but wanted to second your issue.)

I've consistently experienced this on two separate machines over several years. (CentOS7 and Rocky8)

I'm pretty experienced with xdotool and can do all sorts of windowactivate and search stuff but in my experience the --window filter for entering input has never worked.

I've got a variety of objectives, here's a couple:

  • toggling mute in a video call without switching to that window
  • "bypassing" system shortcuts (e.g. google slides uses ctrl+m for new slide but it's already a global shortcut on my system. wanted to use xdotool key --window WINDOWID ctrl+m)

Edit: Just found the aforementioned SENDEVENT NOTES section in the man page (not sure how I missed it) and was able to send keystroke events to xterm without switching to it.... So it sounds like this feature does work, it's just pretty limited to which windows you can send input (which is out of xdotools control)

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.