Easily share mouse and keyboard between a PC and Nvidia Jetson devices without using physical devices, but only a software and the local network.
It often happens to use a PC and an Nvidia Jetson at the same time, jumping from a keyboard to the other and switching the mouse… and starting to use the right keyboard with the wrong mouse, with cables that cross each other in the most frustrating way.
To avoid all these problems it is possible to use hardware devices called “KVM switch” that allows connecting one keyboard and one mouse to multiple devices (usually only two), changing the control simply by hitting a button… and hitting the button… continuously hitting the button… aaaargh.
To avoid losing our mental stability while using our beloved Jetson boards we can use an awesome software called Barrier, which provides the functionalities of a KVM switch and more.
Barrier runs as a server on the machine that physically owns the keyboard and the mouse to be shared, and it runs as a client on the other machines (yes, many clients are allowed). Server and clients must be placed in the same local network and must be connected to their own displays. Changing the machine control is easy like moving the mouse cursor from one screen to the other, like if you are working on the same machine in a multi-display configuration..
And that’s not all, Barrier also provides “clipboard sharing” capabilities, allowing you to copy a text or an image on one device and paste it to the other… you have no idea how useful this is!
Barrier in action
See Barrier in action in the following YouTube video … and don’t forget to subscribe to my channel:
Installing Barrier on the server and clients is straightforward. It can be installed from source or by using ‘apt’, but I prefer using
snap that is the method that gave me minor compatibility problems:
$ sudo snap install barrier
Configure the clients
Barrier can be manually launched when you need it, but it requires a mouse and a keyboard to do it. The best method is to start it when the device boots. I tried starting it as a service by using
systemd, but there is something weird that does not allow it to start in the correct way.
unbuffer command is required to overcome a problem of Barrier with
stdin when automatically executed.
unbuffer disables the output buffering that occurs when program output is redirected from non-interactive programs. Normally,
unbuffer does not read from stdin, this simplifies the use of
unbuffer in some situations, like for barrier.
unbuffer is part of the
$ sudo apt update -y $ sudo apt install expect -y
Configure the automatic start of Barrier on startup launching “Startup application” from the Ubuntu start menu, click
Add and enter the following startup command:
/usr/bin/unbuffer /snap/bin/barrier.barrierc -f --no-tray --debug INFO --name client-machine-name --enable-crypto [server-ip-address]:24800
client-machine-name with the hostname of the client device and
server-ip-address with the IP address of the server machine.
With this method, the automatic login must be enabled, and this is not always possible for security issues. Without automatic login, a physical keyboard is required to enter the login password.
Configure the server
You can automatically start Barrier also for the server, but I prefer to start it manually only when working on the Jetson boards.
A note, the server can run under any kind of operating system, Barrier is available also for Windows and MacOS, the server configuration is always the same and the machines can communicate even if running on different operating systems.
Start Barrier, the first time you must select the language and select the “Server” mode before hitting “Finish”.
Click on “Configure Server” and drag the top right “screen icon” into the grid, near the central icon that represents the server machine. The icon positions must reflect the real position of the different screens of all the machines. This is important to switch from one screen to the other simply by moving the mouse cursor from one to the other., in a very intuitive way.
Now double click on the icon of the client and enter its hostname in the Screen name field. Be sure that the client hostname is correct otherwise the connection will fail.
Click OK and OK again to save the configuration. Finally, click on
Start and the server is ready to accept all the client connections.
There are many other options to configure, like hotkeys to quickly switch between the different machines or dead corners to block switching from some positions; I invite you to test all of them according to your preferences.
Barrier is definitively a must-have tool to work with our Jetson boards. Once you start using it, you won’t be able to do without it.
Please do not hesitate to send me an email if you need support.