Barrier is a free popular KVM software that enables mouse/keyboard sharing across several devices.
I've been fiddling with it for a few hours and I can't seem to get it right.
I have a barrier server running on my Windows machine.
I've downloaded the git repository and built the binaries. I've copied barrier
, barrierc
and barriers
into /usr/bin
.
If I run barrier GUI, specify the server IP and enable the server, it works. I can do it with and without SSL (as long as both the client and the server have the same setting set). I would prefer to use SSL though.
I've then tried running barrierc --enable-crypto <ip>
. The server acknowledges the connection, but says it's not secure and it doesn't work. However, if I run the same command with the -f
flag barrierc -f --enable-crypto <ip>
which makes it run in the foreground, it all works dandy.
Since I'm on Ubuntu 18.04, I've setup a systemd service like so:
[Unit]
Description=Barrier mouse/keyboard share
Requires=display-manager.service
After=display-manager.service
StartLimitIntervalSec=0
[Service]
Type=simple
ExecStart=/usr/bin/barrierc -f --enable-crypto 192.168.12.96
Restart=always
RestartSec=1
User=karlovsky120
[Install]
WantedBy=multi-user.target
I've named it barrier.service
and copied it into /etc/systemd/system/
.
I've tried starting it manually, but it refuses to work. From what I can tell from systemctl
status, it looks like systemd
runs the client, but the client exits immediately and then it restarts it. I've tried with and without the -f
flag, but the result is the same.
The server also complains that the client connection might not be secure, which is the same error you get when you try to connect with a non SSL client to an SSL server. It does so with and without the -f
flag.
I know I have to enable the service to have it run on startup, but how do I get it to work at all?
I got it working for me on Ubuntu 20.04, but the steps probably will not be different on 18.04
You might want to undo your barrier.service first then do the following
I was able to do this more simply I think on a Raspberry Pi 4 running Ubuntu 20.04 with barrier version 2.3.3:
~/.config/Debauchee/Barrier.conf
autoHide
value:Then you can just add
/usr/bin/barrier
(not barrierc) without any arguments into Startup Application preferences.I tested , and i was able to start barrier .
barrier is failing try to read STDIN , by default STDIN is map to
/dev/null
So you need to start barrier with a STDIN map to a file with data
What worked for me was to use the Startup Applications Preferences, but did it a bit differently than the above.
Ran the following:
Opened Startup Applications Preferences, but in my case I just had to browse to the location of "barrierc" and select the correct file. NOTE: The copy and paste didn't work for some reason.
I added the rest and reloaded barrier before computer restart.
Rebooted and it worked.
I installed Barrier as an Ubuntu Snap, as such it's not in /usr/bin/barrier. The PS AUX trick above doesn't work because it references a path that doesn't exist either. I assume some snap related thing.
My path was /snap/bin/barrier.barrierc (for client, barriers for server)
Adjusting the path to that and then keeping all the other CLI options, and putting that in Startup, worked great.
For those needing to be able to log in, I found a work around to running a service. Not sure if it is any more or less secure. For LightDM on Xubuntu (I imagine others have similar options) open Settings > LightDM GTK+ Greeter Settings > Misc. tab
Under accessibility > keyboard Change the prefilled command to
Set to Enabled at start
In Settings > Sessions and Startup > Applications Autostart tab Add barrier
This works perfectly as the lightdb instance stops once login is complete and the desktop instance stops when you log out so there is no conflict.
The only possible issue is if you need the onscreen keyboard in lightdm
A few caveats
I re-imaged my Pi and realized there are a few things that needed to be in place for this to work.
sudo apt install lightdm-gtk-greeter-settings
Under accessibility > keyboard, instead of the command string use only the command "barrier", log out, wait for the barrier gui to appear.
Log back in and change the setting to the command string in the original post.
Raspberry Pi OS by default uses pi-greeter, you need to change this to lightdm-gtk-greeter
This has to be done as root/su, I used sudo mousepad to open mousepad with elivated privileges to open and edit the file.
In etc\lightdm edit the lightdm.conf, on my system it is at line # 108
Change greeter-session=pi-greeter To greeter-session=lightdm-gtk-greeter
Even though its' kinda old thread, when looking for a quick and easy solution unfortunately i didn't find any working systemd service file. So here's mine:
We just have to tell systemd to start the as the user you would normally run the client.
Client:
Server: