14

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

  • 1
    Probably for gdm you need /etc/gdm/Init/Default and for Unity you need to add a script to /etc/init/lightdm.conf. – Rinzwind May 23 '17 at 14:54
  • @Rinzwind lightdm.conf is still too early, even in the post-start section of it, synergy errors out using the same command that works perfectly fine from the terminal. Ubuntu throws an error saying synergy stopped unexpectedly, likely because it can't access the hooks it needs to control the keyboard and mouse yet, need it to happen right when the login screen is displayed so that everything is up and running already – DeeJayh May 23 '17 at 15:36
  • Not terribly helpful but perhaps a little comforting - I struggled with this for about a year before a gave up (GDM) ... I did settle on what I thought was a way it "might" work: two user systemd units, one for a virtual x-server login (think kiosk but not shown), then a trigger to kill that when an actual user logs on. In the end for my use case it wasn't worth it but maybe that helps you. All hail ACME! – Mark May 25 '17 at 23:48
  • If I'm not mistaken synergy needs an X server though, so it can't work without a user logged in – Ziazis May 28 '17 at 20:39
  • Just a wild stab in the dark, but have you tried adding to .xinitrc? – anonymous2 May 30 '17 at 12:02
5
+150

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.

  • 2
    That's acutally really nice! Good to know, just adding it to /etc/lightdm/lightdm.confis enough to make it work completly. Maybe add what he has to add to the answer instead of only linking the ubuntu link. – Ziazis May 30 '17 at 13:13
  • 1
    Spas if you have an auto login, just add synergy to your startup applications. – Ziazis May 30 '17 at 18:20
  • 2
    Pretty sure this works on an older version of Ubuntu, but not on mine. I created /etc/lightdm/lightdm.conf because it didn't exist and put in the two lines above (of course changing it to use my own information) I now have synergy connection when the screen loads up, however I now no longer get the login screen. It's just a blank screen with an X cursor. $ sudo find / -name lightdm.conf gives /etc/init/lightdm.conf and /etc/lightdm/lightdm.confwith the latter being the one I created manually with the two-liner in it. Removing the lightdm.conf I created restores it back to working order. – DeeJayh May 31 '17 at 15:26
  • 1
    I can confirm that, this approach works on 16.04.2! – pa4080 Jun 1 '17 at 15:03
  • 1
    @SpasSpasov I know I'm so excited, I changed the answer to reflect our specifics, waiting on peer review. – DeeJayh Jun 2 '17 at 7:28
1

Go into your startup..for newbies like me do it this way:

  • "search your computer" type in start, click on Startup Applications
  • click Add

    • Name: Synergy
    • Command: browse if you like but its /usr/bin/synergy

    thats it, DO NOT ADD ANY "c", nothing to the end of synergy.

Now I also have the script running because I was too lazy to remove it..so both are there.

[Seat:*]
autologin-user=

[SeatDefaults]
greeter-setup-script=/usr/bin/synergyc --MediaServer 192.168.2.253:port

now to find the port is interesting, its not the default port so do this type in terminal

netstat  -atn

now how I found it was look for your server ip...I know my SYNERGY server ip so right across from it is my client ip and port number.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.