Share your keyboard and mouse between computers with Barrier

Declutter your desk by sharing your mouse and keyboard across multiple computers at once, including your Raspberry Pis, with Barrier. Raspberry Pi Director of Software Engineering, Gordon Hollingworth, shows you how.

Desk clutter is a given

My desk is a bit untidy. Talking to people in our office, you’ll find that it’s mostly because I only clear it properly once a year, or leave it entirely until the next time we move office!

It’s cluttered with Raspberry Pis of random types, with little tags saying what’s wrong or right about each one, and then there’s every manner of SD card, adapter, JTAG connector, headphones, and whiteboard marker pens you can dream of filling the gaps.

But one thing that really annoys me is that I tend to have a mouse and keyboard per computer, and I’ve got at least four computers running at my desk at any one time.

Solutions to this problem have existed for a very long time, known as KVM (keyboard, video and mouse) switches; many people use these to switch (literally with a big toggle switch) between computer 1, 2, and 3 while using a single screen.

But if that’s what you want to do, the best solution is to use VNC on each of the computers so you can use a single display, keyboard, and mouse to access each of their screens and bring them all together.

And, that’s okay, but…

But that’s not quite what I want: I like having the mass-screen real-estate around me, and I like just glancing to the left to see my Raspberry Pi on its own screen.

If only there was a way to share my mouse and keyboard across multiple computers without having to flick switches or unplug USBs.

Well…

Barrier to the rescue!

In the same way one may set up multiple monitors for one computer, and move the mouse cursor seamlessly between them, Barrier allows you to share peripherals between multiple computers, allowing you to host your keyboard and mouse on one computer. It lets you simply drag your cursor from screen to screen, from device to device, as if by magic.

Download and set up Barrier

Barrier is free to use, and simple to set up. You can either follow the video tutorial shared above, or continue reading below:

Download barrier to your main computer

First, download and install Barrier from the developers’ installation page: github.com/debauchee/barrier/releases

At the end of the installation, the application will run. Select the Server option (the server is the one that has the keyboard and mouse that you want to share).

Next select Configure Server. Click on the computer screen in the top-right and drag it to where you want it to appear in relation to the server. It will default to being called ‘Unnamed’.

Next, double-click the new ‘Unnamed’ screen to set it up.

The only thing you need to do here is to set the screen name. Here I’ve changed it to ‘raspberrypi’.  Click OK here and on the Server configuration‘ dialogue. You’ll return to the main Barrier page. Click Reload.

Download Barrier to your Raspberry Pi computer

Now turn to your Raspberry Pi, open a terminal window (Ctrl-Alt-T if you didn’t know), and run:

sudo apt install barrier

Once installation is complete, Barrier should appear in the Accessories drop-down menu, which you can access via the main menu icon (the Raspberry Pi logo in the top right-hand corner). Select Barrier and, this time, choose Client.

If you leave Auto config selected, Barrier should just work, as long as the screen name is correct (you can change this by clicking Barrier and then Change settings) and matches the name you told the server.

And there you have it. You can now use your mouse and keyboard across both your computers. And, if you have enough desktop space for even more monitors, you can continue to add devices to Barrier until your room ends up looking something like this:

A man standing in front of a wall made of computer screens

If you use Barrier to clean up your workspace, make sure to share a ‘before’ and ‘after’ photo with us on Twitter.

60 comments

Mr Wheeliebin avatar

How does this differ to Synergy? It looks like a direct copy. Is it encrypted by default? Synergy is not encrypted for the free version.
Also, does it work well with the server being either Windows or linux? Syngergy can be quite ropey.
Is it open source?

Gordon Hollingworth avatar

It is an open source fork of Synergy, the encryption is enabled by default here.
I’ve not tried it with the server on Linux
Yes it’s open source:
https://github.com/debauchee/barrier/

Douglas avatar

Hi Gordon,
That’s mean it is secure to use even thought I’am typing sensitive information like passwords? What about the security? In the MacOS there is a warning that said: “Barrier” cannot be opened because the developer cannot be verified. MacOS cannot verify that this app is free from malware.
If it is secure to use, will be a great app that I will be using for long, thanks!

Simon Long avatar

All that warning in MacOS means is that the developer hasn’t submitted the application to Apple for code signing. It doesn’t necessarily mean there is anything at all wrong with it; it just means they didn’t want to jump through all of Apple’s (sometimes complicated and expensive…) hoops…

Douglas Navas avatar

Thanks Simon! I will be trying Barrier!

Milliways avatar

I tried on my iMac running Catalina.
The installation was obscure and Barrier kept hiding its settings. I didn’t actually get it to work – although this may be related to my ssh security settings, but the KILLER was that it stopped the Finder Sidebar from showing, so it is presumably doing some fiddling with the Finder code and/or settings. Even purging Barrier from my system was a challenge – it has no uninstall process.

films_de_sf avatar

Hello
I have a problem I followed the procedure to install under Windows 7 and under Raspbian. When I start Barrier on the Raspberry I have this error message: “Please fill in a hostaname for the barrier client to connect to”. So impossible to connect to the server !! Please help me …

andy avatar

uncheck the box next to “Auto config” and then you will be able to enter the IP address of your server in the “Server IP” field.
Once you enter the IP address, you can recheck the “Auto config” box and click “Start”

Mr Wheeliebin avatar

I presume the Barrier people added the encryption bit then. Nice. Free as in free beer.

Misel avatar

> Free as in free beer.
According to the LICENSE file on Github it’s GPL v2. So it’s actually free as in speech and not as in free beer. ;)

Ian avatar

This work looks great, but it is ok if you can see both computers on the same network. I have a USB connector (OEM) to do this at the mo, as one PC runs a VPN, and most VPNs block local network access (eg 192.*) to prevent network bridging.

Jerry Wasinger avatar

What am I missing here? I have multiple screens and usually dedicate one to a VNC session on my RPi when I’m coding.

Ste avatar

I’ve been using Barrier for a few weeks and find it works perfectly. One thing to be aware of is the Print Screen key disables barrier and locks the keyboard and mouse to the currently active screen, pressing again resumes normal operation.

Mark avatar

Gordon, I have run Synergy server on a Pi and on a PC Linux box with Mint and it works very well. The only problem I have ever had with Synergy is getting Windoze clients to connect automatically. This is presumably due to having a password protected login set up on the Windoze clients.

John H avatar

@Jerry – the way I’ve been using Synergy (of which Barrier is a fork) for years is to use one keyboard/mouse for multiple computers. So if you had a monitor on your raspberry pi, you wouldn’t need to keep two keyboards on the desk. For instance, I have my Windows work laptop, my Macbook, and my linux desktop. I can move seamlessly between them throughout the day using the same keyboard and mouse, sharing clipboard contents.

Mark avatar

Jerry, it sounds like you have multiple monitors on a single PC and connect to another computer over VNC with it’s video output being displayed on your [second] monitor. Synergy (or Barrier) allows your mouse pointer to move off the edge of your screen and onto the screen of another computer on the same network, taking the keyboard and clipboard with it and allowing you direct control of that second (or third, or fourth, etc) computer, whether it is a PC, Windoze box, Mac or Pi.

Dave avatar

A word of warning for polyglots: Barrier is fundamentally flawed in that it send over characters (letters you typed) instead of scan codes (which physical key you pressed).
This makes barrier virtually unusable with multiple keyboard layouts.
For example I want to type a 4 on one of the clients with English QWERTY layout. But on the host I have Czech QWERTZ selected. So I press the 4 key, which tries to type č, but since there is not č on an English keyboard it types a c. So I press 4 and get c.
It usually works if you make sure both host and client have the same layout selected, but that’s very tedious and even then it still breaks sometimes for non-english layouts.
It’s a nice concept, but it only works if you’re using English and nothing else.

Paul Webster avatar

Just tried with Windows 10 as host.
Appeared to be working well until I tried to type vertical bar on RPi terminal session … and it appeared as greater-than sign.
So – issue with keyboard language.
My Win 10 is configured as UK keyboard – as is my RPi and a directly attached USB keyboard on RPi correctly shows UK keys as typed.
Starting new new terminal session on RPi did not resolve it.

Paul Webster avatar

Seems others have similar problems
https://github.com/debauchee/barrier/issues/638

Harry Hardjono avatar

There’s nothing stopping you from connecting a monitor to a Raspi when it’s broadcasting VNC. The way VNC works is by mirroring the display. So, you can always see what’s happening on the other computer. Of course, you then duplicate the screen if you want to work on it. But I prefer that way since I don’t want to crank my neck sideways for too long, anyway.
Still, more options is better since everyone works differently. Thank you for posting.

W. H. Heydt avatar

Interesting…. Unfortunately, I don’t have room for a second (let alone third, fourth, fifth…) monitor on my desk. So it’s KVM switches for me. I got my first one over 20 years ago and have never looked back.

Justin avatar

What GTK theme is the Pi using? It’s nice!

Mikael Bonnier avatar

I developed this similar system in 2016 that works with computers using X: https://github.com/mobluse/x2x
It uses x2x.

Adrian avatar

Jerry,
The main thing you’re missing is latency free, realtime graphics.

Ted avatar

Does this work with dual monitors?

Bob avatar

I have 6 pi screens that I switch back and forth and would like get this running. I did the apt install and it is in my accessories folder. I call it up and get the main box. click on Client (I have already got it installed on my mac). I click on apply then nothing happens! Also tried to get the tarball and build it, but it says that I dont have access rights to the remote repository.

Anders avatar

My Pis generally run web apps on Raspbian Lite, so command line interface only, SSH is all I need.
But this looks interesting for some of our office Pis that have big screen displaying infrastructure status.

Jerry Wasinger avatar

@Adrian and @Mark, I just realized I did not read the explanation of Barrier very well – now I get it. This code allows the use of a single KBD/Mouse across multiple computers. However, they each connect to a dedicated monitor. Think I’ll stick with my VNC solution since it allows me to drag my RPi desktop over to my main screen when I want it front and center.

Ricky avatar

I’ve been using Synergy for a few months and love it. I have a windows 10 tablet as the client, I just use for Spotify, notes, a task listet and have it positioned under my monitor.

Dan avatar

Does it work between a laptop screen and a monitor?

thagrol avatar

I remember doing something similar more than a dozen years ago.

vnc server on the keyboard/mouesless machine combined with a vnc client on the main machine that didn’t display the remote machine but detected the pointer moving off the local screen then sent keyboard/mouse input to the vnc server.

Worked fine unless the vnc server crashed when the client had grabbed the pointer and keyboard. Hopefully Barrier (and synergy) have fixed that type of issue.

steven avatar

What are it’s technical requirements?
By example, does the Server’s processor or RAM impact it’s capabilities?
If I were to use a Raspberry Pi 4 as a server, because it supports two monitors, would there be any advantage in using a Pi with more RAM?

Mario avatar

This is very appreciated and so easy to set up! Thanks!

Mario avatar

How would you set barrier to starting automatically after login in raspbian?
I have googled and only found how to run python programs after booting. There must be a simpler way to set this as in other OS.

Norman Dunbar avatar

You could put the command to start barrier into /etc/rc.local, with an ampersand (&) at the end.

Cheers,
Norm.

Ron avatar

Doing a sudo apt install barrier gives me the Unable to locate package barrier error on raspberry pi

Wayne Linton avatar

You are probably running Stretch on a 3b? It’s all done by hand …

https://github.com/debauchee/barrier/wiki/Building-on-Linux

Ste avatar

@Mario,
It took me a while to figure out how to get Barrier to autostart.
Firstly make sure that your barrier connection is working and then exit Barrier (Barrier > Quit), this saves the current settings.
In the file /home/pi/.profile add this to the end of the file
barrier &
Save and restart.
Ste

Jonathan White avatar

Trying to do the same but can’t find that file. Only have a.txt and rpdiags.txt in that folder.
I am new to this.

Jonathan White avatar

To access file.
open terminal and use sudo mousepad /home/pi/.profile

Thorsten avatar

@Ron,
You’ll most likely have to upgrade your Raspbian to Buster.

andrum99 avatar

I managed to get this working on my Pi 4 using my WIndows 10 laptop as the server. I had to use the workaround in https://github.com/debauchee/barrier/issues/134 to get the keyboard layout on the Pi correct – without that it gave me a US keyboard layout – both Pi and laptop set to UK keyboard layout already (including system locale on Windows 10).

Esbeeb avatar

I really appreciate video tutorials like these. :) Very helpful.

SingingCoyote13 avatar

could not have expected this to be possible, never thought of this. lol

archie avatar

Nice Thing. Works great for me. But i would like to see a version for Android too. I’m using Samsung Dex for some applications for work (MS Office, Outlook etc.) cause i don’t use Windows anymore. Then i could work with only one keyboard and mouse.

David Norman avatar

Great program use between my PC and pi4. Please note if you not running windows standard 100% fonts can casue problems with mouse pointer . Also as a gamer I had to turn on “switch on double tap” which means have to hit side of screen 2x fast to switch over.

paul williams avatar

This looks great. I am fairly new to pi’s and raspian etc. I have tried installing using : ‘sudo apt install barrier’ after ‘sudo apt-get update’ and it shows ‘Reading package lists… Done ; Building dependency tree; Reading state information… Done; E: Unable to locate package barrier.
Im confused as I believe i followed the instructions in the video

Hans Wilhelm avatar

Did you follow up the update command with ‘sudo apt upgrade -y’ ?

Bradon avatar

that’s not even close the package isn’t even in the package manager

Teslicek avatar

Thank you so much. I didnt think this would be possible but now I’ve connected my mouse and keyboard with Laptop and Rpi4. Thanks again!

Muhammad Shakeel avatar

Thank you so much i was looking this article but now follow your instruction i have done thanks again

John avatar

Looks very interesting. Might give it a go. Thanks

Marlon Fraile avatar

Thank you, Gordon. It is a great tool and useful video

Cedar avatar

My Rpi2 2 couldn’t find “Barrier” – I tried twice – first with the sudo prompt. E=”unable to locate package barrier”. I then “sudo apt install github.com/debauchee/barrier/releases. Same result. E=couldn’t find any package by regex ‘github.com/debauchee/barrier’.
What am I doing wrong?

Ian avatar

I had the same issue.

There is a note on the git saying they have moved to “flat hub”.
There is some steps to install flat hub, and then get barrier.
I was able to download it, but not properly install it.
I searched the pi, found the barrier file and ran it manually ….. and amazingly it worked and linked to my PC. happy days.

Mike avatar

Thanks Gordon, brilliant article for great idea; really helpful as I inevitably attempt to enter commands using the wrong keyboard!
Using information you have provided I have set it up and “sort of” got it working but with some issues, perhaps you can give some pointers of what I am or am not doing correctly. I am using it between a 32bit Linux Mint (19.1) as server and for purpose of testing here an entirely fresh Rasberry OS down loaded onto a RPi3B as client.
Mint Server installs as expected and seems to work fine, customisation is made to indicate it as server with a client of “raspberrypi”.
Barrier install on Raspberry client seems to proceed clean per your instructions however it does not appear in the applications list and the only way I seem to have to initiate it is to type “barrier” into a terminal and this will then bring up the customizations box. From the customizations box, ticking the auto box in client does not do anything helpful, however if I type the server ip address into the client field this is accepted and after confirming identity of server I’m up and running with shared keyboard/mouse. On closing and restarting the RPi none of the configuration is saved and requires it to be restarted from a terminal window.
Clearly I am missing or not doing something, any thoughts appreciated.

Henrik Lauridsen avatar

This Barrier is brilliant. Thank you

Les Mikesell avatar

I have my pi connected to a TV and use vnc or x2go when I want to have normal access from another computer (and by the way, my preference is x2go to a MATE session which is not connected to a physical screen). I was hoping to be able to use my laptop as the controlling keyboard with barrier when running Kodi as a media player on the pi with output to the TV, though. This works with Plex and most other programs but Kodi seems tied to the physical keyboard (doesn’t work with VNC either). Does anyone know a way around this?

Garrett Cassidy avatar

I want a fresh windows install so I can install bonjour. Now when I uninstall and reinstall it doesn’t ask me the fresh install questions.

João Eduardo dos Santos Dias avatar

I installed Barrier on Windows 10, but in Log it keeps saying:
“barriers.exe: no configuration available”
Tryed to save configuration in other file, bu it’s the same…

What can I do?

Comments are closed