I have installed xdotool on my raspbian stretch with desktop and on there, everything works fine. But I also tried to install xdotool on raspbian stretch lite and on lite I always encounter the following error:

Error: can't open display: (null)
Failed creating new xdo instance

What I have also tried: I flashed raspbian stretch lite on my SD card and installed xdotool with sudo apt-get install xdotool and tested it with the command xdotool key "1". I got the error shown above.

After that I have updated from lite to desktop with sudo apt install raspberrypi-ui-mods. Then I ran xdotool key "1" again and now it works fine.

Does someone know if my guess, that xdotool only works with gui is correct.

Or does someone know how to get xdotool on rasbian stretch lite without desktop to work?

1 Answer 1


You can get information about xdotool with:

rpi ~$ apt show xdotool
Package: xdotool
Version: 1:3.20160805.1-3
Priority: extra
Section: x11
Maintainer: Daniel Kahn Gillmor <[email protected]>
Installed-Size: 104 kB
Depends: libc6 (>= 2.15), libx11-6, libxdo3 (>= 1:3.20150503.1)
Homepage: https://www.semicomplete.com/blog/projects/xdotool/
Download-Size: 50.5 kB
APT-Sources: http://raspbian.raspberrypi.org/raspbian stretch/main armhf Packages
Description: simulate (generate) X11 keyboard/mouse input events
 xdotool lets you programmatically (or manually) simulate keyboard
 input and mouse activity, move and resize windows, etc. It does this
 using X11's XTEST extension and other Xlib functions.

As you can see its from Section x11 and the Description also says that it is for X11 keyboard/mouse input events. X11 is the graphical environment on Unix. You can show what would be installed with:

rpi ~$ sudo apt --simulate install xdotool

You can install it if you omit the option --simulate. I have done it on Raspbian Lite. On the plain serial console I tried:

rpi ~$ sudo xdotool mousemove 0 0
Error: Can't open display: (null)
Failed creating new xdo instance

That is as expected. There is no window where the mouse cursor can be moved. For me, using xdotool without GUI makes no sense. Maybe you have a better usage on Raspbian Lite. Tell me.

  • isn't there a way to examine on which packets xdotool depends on and install them isolated?
    – J.Doe
    Mar 10, 2019 at 20:27
  • @J.Doe I have updated my answer.
    – Ingo
    Mar 10, 2019 at 21:17
  • ok seems like installing the desktop is the only way to go. I have a JavaFX application running on my Raspbian lite and therefore I also needed to install some additional GUI packages, but apparently these packages aren't the one xdotool wants to have.
    – J.Doe
    Mar 10, 2019 at 21:54
  • @J.Doe Does my answer help you or answer your question? If so, it would be nice if you could accept and/or upvote it. Accepting it would show others that it has a solution.
    – Ingo
    Mar 10, 2019 at 23:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.