0

I am a beginner to Linux and really having fun using it so far, but it seems that there is a problem I cannot solve, or at least don't quite understand -- The xdotool from X11 Project doesn't work on Ubuntu under either my VirtualBox installation or my Windows WSL installation.

I have done everything I can but still no luck.

  • My VirtualBox Ubuntu Release is 22.10, and yes I am using Xorg not Wayland.
  • In WSL, I downloaded the Xming X Server for Windows from sourceforge.com.

Here is what I did in both of them:

sudo apt update 
sudo apt  install xdotool
xdotool type "hello"

Nothing happens ... no errors, nothing.

Both WSL and VirtualBox Ubuntu's have the same exact response -- Nothing.

Example

NotTheDr01ds
  • 17,888

1 Answers1

1

I can't speak to what's happening in your VirtualBox installation (but I suspect it's something similar). The issue with WSL, at least, is that you don't appear to have an X application running in which to target the output of Xdotool. If you do, you don't mention it, at least.

It's an easy mistake to make -- I did it myself just a few days ago when trying something out.

Just running the X server doesn't give it a target application. You would need to be running the command above in an X terminal application, such as Xterm in order to see the results.

The terminal in which Ubuntu is running under WSL is not, of course, an X application; it's a Windows application.

Also note that you shouldn't even need Xming any more for this to work. All recent releases of WSL support GUI applications directly. See this answer for more information. It's doubtful that the KB patch is even needed any longer, as it should be integrated into the mainline monthly servicing releases at this point.

With that installed, remove any changes to the DISPLAY variable that you put in place for Xming. The stock WSL should manage DISPLAY correctly.

Then:

sudo apt install xterm

From WSL, run xterm. And inside that Xterm terminal, run your:

xdotool type "hello"

You should see the Hello entered at the next prompt-line in Xterm.

Note that, according to this answer many applications do not accept "sent" keystrokes unless they are already the foreground application. This is for security reasons.

NotTheDr01ds
  • 17,888
  • I'm puzzled about the OP's lack of success in VirtualBox as well - I wonder if it's terminal dependent? It works for me in a Lubuntu 22.04 VM, with both qterminal and xterm. – steeldriver Feb 28 '23 at 21:01
  • I Think i broke my Display variable. This error keeps showing (xterm: Xt error: Can't open display: xterm: DISPLAY is not set) – fahad almarri Mar 01 '23 at 10:41
  • Regarding @steeldriver. Actually xdotool worked on my VB. It appears that i had to logout of ubuntu then choose XORG before logging back in to my account. XD – fahad almarri Mar 01 '23 at 10:46
  • God Bless @NotTheDr01ds It works!! Regarding my Error, IT that "DISPLAY is not Set", it appears there is a file, located in my root dir called .wslconfig that contains the following: [wsl2] guiApplications=false . i just changed it from false to true – fahad almarri Mar 01 '23 at 11:20