In some situations, it can be useful to simulate user events on a keyboard or mouse, without an actual keyboard or mouse. The original idea that made me look into this subject, was that I wanted to run RetroPie on my Raspberry Pi with different ways to control the system. Instead of a keyboard, I wanted to use GPIO inputs (buttons or joysticks), or even a web interface that I could access from my phone. We’ll use a program called xdotool to do this.
The Raspberry Pi is a small single board computer that was originally intended for education and developing countries. In the last 5 years, it achieved way more than this, as it is now one of the best and easiest platforms for tinkerers and DIYers. It is basically a full Linux computer with a small form factor and energy consumption, making it ideal for homemade projects. Most of the time, you can use the Raspberry Pi as a headless machine, without a monitor, keyboard or mouse, and just use Telnet or SSH to access it. This considerably reduces the total cost of a project, as there will be no need to buy a screen, keyboard or mouse. However, the tricky part of this setup is the first installation of the OS. In this tutorial we’ll learn how to set up a Raspberry Pi in a fully headless way.