16

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

DeeJayh
  • 378
  • 1
  • 4
  • 17
  • 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
  • Use systemd timer or crontabe to run the command on boot. – mini May 30 '17 at 15:36
  • @mini that doesn't work because it's called before the xserver, therefor it isn't able to hook into the keyboard or mouse – DeeJayh May 31 '17 at 15:34
  • @anonymous2 .xinitrc is a no-go, but thank you for trying. – DeeJayh Jun 01 '17 at 03:30
  • @Ziazis it was possible in the past according to https://help.ubuntu.com/community/SynergyHowto#Autostart_Synergy_before_logging_in_.28GDM.29 so why not now? – DeeJayh Jun 01 '17 at 03:34

2 Answers2

7

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.

Zanna
  • 70,465
jringoot
  • 838
  • 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
  • This approach definitely works, but in within my system, when there is auto-login user some error is generated. – pa4080 May 30 '17 at 17:03
  • 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
  • DeeJayh, the only difference I have for myself is that I have in the first two lines my autologin which I removed. so my first line is [Seat:*] and second line is autologin-user= it's a longshot but maybe try adding at least the [Seat:*] as your first line or just both? – Ziazis Jun 01 '17 at 06:25
  • 1
    I can confirm that, this approach works on 16.04.2! – pa4080 Jun 01 '17 at 15:03
  • @Ziazis putting all 4 lines of code worked! – DeeJayh Jun 02 '17 at 07:28
  • 1
    @SpasSpasov I know I'm so excited, I changed the answer to reflect our specifics, waiting on peer review. – DeeJayh Jun 02 '17 at 07:28
  • Note that if you are just using the synergy server's IP set the last line of code to: greeter-setup-script=/usr/bin/synergyc 192.168.x.x – BitBug Apr 02 '18 at 00:40
  • One more thing to add with the latest versions, I was unable to get this to start as a client until I added --enable-crypto (1.10.3) – DerfK Sep 10 '19 at 02:31
2

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.

muru
  • 197,895
  • 55
  • 485
  • 740