Share Your Keyboard and Mouse Between Linux and Raspberry Pi

This DIY tutorial teaches you to share mouse and keyboard between multiple computers using open source software Barrier.
Warp Terminal

I landed in a situation where I had two monitors connected to my laptop and I wanted to use a Raspberry Pi in the mix.

Since I only needed to use the Pi occasionally, it made no sense to get a dedicated keyboard for it. And thus I decided to share my keyboard and mouse between the two devices.

Actually, there are two ways to handle this issue:

  • Hardware: Get a keyboard mouse pair that can switch between devices. Some keyboards allow you to switch between 3 devices using RF and Bluetooth combination. You may always use KVM switch to change the output device.
  • Software: You use a tool like Barrier or its fork Input Leap (both explained in detail in this article).
📋
If you could, go for a keyboard mouse pair that allows connecting/switching between multiple devices. That will be a convenient option. The software method takes some effort but it could be a solution when you want to learn something new and don't want to spend on new hardware.

If you cannot go for the hardware solution, try the software based approach to share the keyboard and mouse between computers.

The set-up

Barrier used to be the go-to software for this kind of approach but it has not seen new development in years. An earlier version of this tutorial used Barrier, and the instructions can still be followed in the PDF here.

I used Input Leap, a fork of another open-source project called Barrier. The architecture of this setup is simple. You setup Input Leap in server mode on the system where keyboard-mouse is attached. And then you setup Input Leap or Barrier in client mode. Why Barrier? I'll discuss it later in the tutorial.

Sharing keyboard mouse with KVM software Input Leap and Barrier

The process involves this:

  • Installing the Input Leap software on all the devices you want in this sharing setup
  • Setting up the software on the system with keyboard-mouse in server mode
  • Setting up the software on the system(s) without keyboard-mouse in client mode
  • Using the software to switch between the devices
💡
Did I mention that you can even share clipboard and thus copy paste text between the computers using Input Leap? That's awesome, isn't it?

Let’s see how to share the mouse and keyboard with multiple computers using this method.

Installing Input-leap on Debian (using pre-built releases)

The developers of Input Leap have kindly provided pre-built releases on their GitHub page. This is the easiest way to get started.

Download the Pre-Built Package

Visit the GitHub releases page and download the .deb file that matches your system’s architecture (e.g., amd64).

input-leap github release page

Install the Package

sudo dpkg -i input-leap-*.deb
installing input-leap from terminal

Start Input Leap

Run the Input Leap server on your device:

running input-leap for the first time, initial welcome screen

Now you are ready to start input-leap:

configuring input-leap as a server on deb-vm

That’s it! Your Debian system is ready to share its keyboard and mouse.

once input-leap is running, you can close the application and it will work in the background.

Configure the client on your secondary device(s).

Building input-leap from source (for Raspberry Pi)

If you can’t find a suitable pre-built release, or you’re using a platform like Raspberry Pi, you’ll need to build Input Leap manually from source.

🚧
Building from source could be intimidating and often not worth the effort. If it scares you, you can try installing barrier on Raspberry Pi as it is available in Debian repositories. Input Leap as server and Barrier as client works fine, too.

If you still decided to go for source code installation, here are the steps.

Install build dependencies

Ensure your system has all the necessary tools and libraries installed:

sudo apt-get install -y \
                  cmake \
                  g++ \
                  git \
                  libavahi-compat-libdnssd-dev \
                  libcurl4-openssl-dev \
                  libice-dev \
                  libsm-dev \
                  libssl-dev \
                  libxinerama-dev \
                  libxrandr-dev \
                  libxtst-dev \
                  libxkbcommon-dev \
                  libglib2.0-dev \
                  ninja-build \
                  qtdeclarative5-dev \
                  qttools5-dev \
                  meson
installing input-leap dependencies

Clone the repository

Fetch the source code:

git clone --recursive https://github.com/input-leap/input-leap.git
cd input-leap/
cloning input-leap git repository

Build the project

First, create a build directory and configure the build system:

cmake -S. -B build
configuring the build files in the build directory

Then, compile the project:

cmake --build build
compiling the build from source

Install Input Leap

Finally, install the compiled binaries:

sudo make install
installing input-leap after compilation

Set up Input Leap as the server

📋
You do it on the computer that has keyboard and mouse attached to it.

Once you build and install Input Leap, you won’t find its icon in the main menu bar. To access it, simply type:

input-leap

This will launch Input Leap in GUI mode, and a welcome window will pop up, guiding you through the initial setup.

to run input-leap for the first time, it requires typing it in the terminal

Next, it will prompt you to select a role as either a server or client. Choosing a server means your device will share its keyboard and mouse with other systems, while selecting client allows the device to receive inputs from the server.

select the role of your input-leap: as a server or a client

And voila! You should see an IP address and an SSL fingerprint. It’s not entirely done because you have to configure the server a little. Click on Configure Server option.

configuring the input-leap as server on raspberry pi

In here, you should see your own system in the center. Now you have to drag and drop the computer icon from the top right to a suitable position. The position is important because that’s how your mouse pointer will move between screens.

server configuration, drag and drop pane to add clients

I have my Acer laptop connected and a Debian virtual machine as a client.

Do note that you should provide the hostname of the client computer. In my case, it was ACER and deb-vm. It won’t work if the hostname is not correct.

Don’t know the client’s hostname? Don’t worry, you can get it from the client system.

🚧
Input Leap does not support Wayland. If your system uses Wayland, you’ll need to switch to X11 or consider alternatives like Barrier. I learned this the hard way after extensive testing.

Set up the client

On the second computer, start input-leap and choose to use it as client.

selecting role of input-leap as a client

You need to provide the IP address of input-leap server. You can find this IP address on the input-leap application running on the main system, in my case on my Raspberry Pi (see the screenshots in previous section).

adding the ip address of the server to the client input-leap menu

If you see an option to accept secure connection from another computer, accept it.

accepting ssl prompt to connect the client to the server

You should be now able to move your mouse pointer between the screens connected to two different computers running two different operating systems. How cool is that!

Mix-and-match: Using input leap and barrier together?

During my initial attempts, I couldn’t get input-leap to build successfully on my Raspberry Pi. As a workaround, I used Barrier on the Pi and Input Leap on my Windows PC.

Surprisingly, this setup worked flawlessly! Both tools use the same protocol, making them interchangeable in many scenarios.

Conclusion

An earlier version of this tutorial used Barrier in the complete setup. If you want to do that, the older tutorial instructions are available in this PDF.

Input Leap is a powerful tool for managing multiple devices with ease, but it comes with some caveats, particularly for Wayland users.

If you’re comfortable building software from source, Input Leap offers a seamless experience.

For those encountering challenges, Barrier provides a reliable fallback. With this guide, you can simplify your workflow across Linux, Raspberry Pi, and Windows systems. Happy tinkering!

About the author
Abhishek Prakash

Abhishek Prakash

Created It's FOSS 11 years ago to share my Linux adventures. Have a Master's degree in Engineering and years of IT industry experience. Huge fan of Agatha Christie detective mysteries 🕵️‍♂️

Become a Better Linux User

With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world

itsfoss happy penguin

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.