Ubuntu – Start Synergy (or any application) BEFORE logging in Ubuntu 16.04.2 LTS

16.04bootstartup-applicationssynergyxserver

Using Ubuntu 16.04.2 (Xenial) on Intel x64:{Both Processor and Ubuntu install}

This question has been answered a million times, but none of the solutions work. So I don't want to duplicate a question, but it hasn't been answered.

When I fire up a terminal and sudo -i, the following command works just as expected.

`root@user-pc:~# /usr/bin/synergyc -f --no-tray --debug INFO --name 
 user-pc 192.168.xxx.xxx:24800
 [2017-05-23T09:20:44] NOTE: started client
 [2017-05-23T09:21:01] NOTE: connecting to '192.168.5.100': 
 192.168.5.100:24800
 [2017-05-23T09:21:01] NOTE: connected to server`

I am then able to utilize the program for it's purpose. However, I want this to be done automatically before login so that I can utilize it's purpose from the login screen. (Synergy allows you to use one keyboard and mouse across multiple computers, almost like a virtual KVM but instead of hitting switches, you just roll your mouse right onto the next screen as if they were all attached to one graphics card)

The first thing I tried was rc.local:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

exec /usr/bin/synergyc -f --no-tray --debug INFO --name user-pc 192.168.5.100:24800

exit 0

~~~ls /etc/rc.local -l:

-rwxr-xr-x 1 root root 390 May 22 20:56 /etc/rc.local

So it's definitely executable, but upon rebooting the PC:

~~~ps aux | grep syner:

`root  990  0.0  0.0  63656  5372 ?  Ssl  09:33  0:00 
 /usr/bin/synergyc -f --no-tray --debug INFO --name user-pc 
 192.168.5.100:24800`

However it isn't doing what it is supposed to, even unity dialogs are being called saying something went wrong, which only happens when this executes, so I can safely assume it's that.

My safest assumption is that the program is being run just fine, the problem is that rc.local is run prior to the x session starting so any hooks to the keyboard and mouse are never established, which is also likely only done at the beginning of execution of synergyc and not attempted again beyond that point.

The second thing I tried was "Startup Applications", it works, but not until after login, which is not what we want going on here.

If my assumption is correct:

What is a way to call execution of a process after the x server is up, but before any user has to login.

If my assumption is not correct:

Help

Best Answer

For 16.04.2 create the following file (it doesn't exist)

/etc/lightdm/lightdm.conf

with the contents:

[Seat:*]
autologin-user=

[SeatDefaults]
greeter-setup-script=/usr/bin/synergyc --name <hostname> 192.168.x.x

Follow this ubuntu wiki guide for more information.


EDIT:

From man synergyc:

STARTING AUTOMATICALLY...

options must not include -f or --no-daemon. It's important to make sure no old copies of synergy are running so they can't interfere with the new one.

Related Question