Setting up barrier to run on startup

22,835

Solution 1

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

  1. Get a working setup using keyboard and mouse at your client Ubuntu, note down [name of your client/screen]
  2. Open terminal and get the full cli commands equivalent of current working setup without using configure file i.e. run "ps aux | grep barrier"
user@hp-eo800-g1-aio-u:~$ ps aux | grep barrier
user        1278  0.0  0.1  98896 10256 ?        Sl   Nov16   0:29 /usr/bin/barrierc -f --no-tray --debug INFO --name [name of your client/screen] --enable-crypto --log /var/log/barrier.log [SERVER IP ADDRESS]:24800
user       14737  0.0  0.0   9036   668 pts/0    S+   09:41   0:00 grep --color=auto barrier
user@hp-eo800-g1-aio-u:~$ 
  1. Notice the last part of ps output, that'd the full command with all parameters you need run your Ubuntu as a client, copy it
/usr/bin/barrierc -f --no-tray --debug INFO --name [name of your client/screen] --enable-crypto --log /var/log/barrier.log [SERVER IP ADDRESS]:24800
  1. Create a new entry in the Startup Applications Preferences New entry in Startup Applications Preferences and paste the command to Command section as seen in attached screen cap
  2. Reboot now to test that it will auto kick off as your Desktop manager is brought up.

Solution 2

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:

  1. Edit ~/.config/Debauchee/Barrier.conf
  2. Set the autoHide value:
    autoHide=true
    

Then you can just add /usr/bin/barrier (not barrierc) without any arguments into Startup Application preferences.

Share:
22,835

Related videos on Youtube

Karlovsky120
Author by

Karlovsky120

Updated on September 18, 2022

Comments

  • Karlovsky120
    Karlovsky120 over 1 year

    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?

    • s1mmel
      s1mmel over 4 years
      Could be that the program does not like self-signed certificates. Maybe you try to create a certificate with let's encrypt?
    • Karlovsky120
      Karlovsky120 over 4 years
      The program works fine if I run it directly from the terminal, in foreground, but throws a fit if I run it in the background or if I try to run it as a service. Since it does work, I doubt that certificates are the problem.
    • s1mmel
      s1mmel over 4 years
      Try to start it with nohup and take a look into the logs.
    • Karlovsky120
      Karlovsky120 over 4 years
      I got no useful info from it.
    • ttfreeman
      ttfreeman about 4 years
      @Karlovsky120 have you solved this problem with barrier?
    • Karlovsky120
      Karlovsky120 about 4 years
      No, I haven't...
    • Jason Kelley
      Jason Kelley almost 4 years
      I'm having the exact same problem. Anyone solve this yet?
    • EchoMike444
      EchoMike444 almost 4 years
      @JasonKelley can you test my Answer
  • Jason Kelley
    Jason Kelley almost 4 years
    What data would you put in /dev/zero? Barrier doesn't need any input from STDIN.
  • EchoMike444
    EchoMike444 almost 4 years
    /dev/zero is a char device , you can read read and it contains only a infinite value of zero . the device is already here . ls -la /dev/zero
  • EchoMike444
    EchoMike444 almost 4 years
    @JasonKelley , i did not dig into the code but barrier ( or ldependencies ) read and one moment STDIN . But i found it by running strace
  • EchoMike444
    EchoMike444 almost 4 years
    you can prove by running manually , that barrier will fail if you run /usr/bin/barrierc -f --enable-crypto 192.168.12.96 </dev/null