In Ubuntu 20.04, I am trying to write a very small script to bring a specified window to the foreground and then send a key combination on this window.
For that I am using:
#!/bin/bash
xdotool search --onlyvisible --class <myWindow> windowactivate %@
xdotool key ctrl+alt+p
Now, while the specified window in <myWindow> is indeed coming to the foreground, the key combination seems to not have any effect, no error showed or anything like that. However, it does have the desired effect if I send the combination manually with the keyboard and with the window in the foreground.
I also tried adding a little delay sleep 2 between the 2 commands, no luck so far.
Missing something here?
except
windowactivatemaybe also
windowfocusand little
sleep?maybe also
--syncman xdotool
windowfocus [options] [window]
Focus a window.
Uses XSetInputFocus which may be ignored by some window managers or programs.
--sync After sending the window focus request, wait until the window is actually focused.
windowactivate [options] [window]
Activate the window.
This command is different from windowfocus: if the window is on another desktop, we will switch to that desktop. It also uses a different method for bringing the window up.
I recommend trying this command before using windowfocus, as it will work on more window managers.
--sync After sending the window activation, wait until the window is actually activated.