Jump to content
Get SynergyOpen a support ticket

Auto start on Linux before login


Recommended Posts

I'm not sure if this is relevant to Synergy 2 - but the post I made here:

is what I use with Synergy 1 and my headless CentOS 7 machine, works fine for me at least.

Link to post
Share on other sites
  • 1 month later...

I've tried what you posted in the other thread.

Synergy is started as a client before login, however, it will not connect to the server until I actually login to the linux box

Link to post
Share on other sites
  • 3 weeks later...
  • 2 weeks later...
Terror-Byter

I really should have done my homework before buying this software.

I didnt see a demo or trial version, and since I know this software has been out for a while, I just "Assumed" that it would have some kind of autostart feature...

I have two machines, one Windows 10 and one Ubuntu 18.04, and I got this so I didnt have to keep unplugging my keyboard and mouse to plug it in to the other machine when needed.

Well... I still have to unplugg the keyboard and mouse to start Syngergy on the client Machine... kinda defeats the point of having a software KVM dont you think?

Please please can you add an autostart feature so that my 30 bucks dont go to waste... I could have just bought another keyboard for 30 bucks...

Link to post
Share on other sites
43 minutes ago, Terror-Byter said:

I really should have done my homework before buying this software.

I didnt see a demo or trial version, and since I know this software has been out for a while, I just "Assumed" that it would have some kind of autostart feature...

I have two machines, one Windows 10 and one Ubuntu 18.04, and I got this so I didnt have to keep unplugging my keyboard and mouse to plug it in to the other machine when needed.

Well... I still have to unplugg the keyboard and mouse to start Syngergy on the client Machine... kinda defeats the point of having a software KVM dont you think?

Please please can you add an autostart feature so that my 30 bucks dont go to waste... I could have just bought another keyboard for 30 bucks...

Just ask for a refund.  I got mine pretty quick.  I can't believe this isn't still a thing.  Must not be possible.  

Link to post
Share on other sites
  • 3 weeks later...
Xerotope

In case this helps anyone, I finally bothered to get Synergy to auto-start before login for Kubuntu 18.04 (sddm login manager/KDE plasma shell).  I'm using systemd to start the process by creating a service file at /etc/systemd/system/synergy.service

[Unit]
Description=Synergy Service
Requires=display-manager.service
After=display-manager.service

[Service]
Type=simple
Restart=always
RestartSec=3
ExecStartPre=/bin/bash -c "sleep 10; /bin/systemctl set-environment SDDMXAUTH=$(/usr/bin/find /var/run/sddm/ -type f)"
ExecStart=/bin/bash -c "XAUTHORITY=${SDDMXAUTH} /opt/synergy-core/build/bin/synergyc -f -n minotaur 192.168.0.150"


[Install]
WantedBy=graphical.target

(replace "/opt/synergy-core" and "minotaur" with the path to your install of synergyc and your hostname respectively).

You then can enable the service at startup with "sudo systemctl daemon-reload; sudo systemctl enable synergy.service"

The ExecStartPre was necessary because the XAuthority file used by SDDM in randomly generated when the process starts.  The "sleep" is a bit of a hack to ensure the file was created after the display-manager.service starts.

Hope that's helpful for someone out there!

Dean

Link to post
Share on other sites

@Xerotope

Thanks Dean,

How would I have to modify the ExecStartPre statement if I'm using gnome and LightDM as the display manager?

So far, I don't have that statement.

instead, I have 

User=myUser
Group=root

 

the problem I have so far is that it does not work upon reboot. 

For it to work, I have to login (via other means) to the GUI, and then restart the service

Thanks for your help,

Marcelo

Link to post
Share on other sites
Xerotope

I don't have the time to boot my machine with LightDM as the display manager right now, but google suggests it might be /var/run/lightdm/root/0.  Maybe see what's there in your system?   (If it doesn't change every boot, you don't even need the ExecStartPre and just hard code the path into the value of XAuthority).

It would probably be cleaner to have a script that isn't dependent on a specific display manager.

Link to post
Share on other sites

@Xerotope

Oh, well, I hardcoded:

SDDMXAUTH=/var/run/lightdm/root/:0

and I still have the same problem, the service client does not connect to the synergy server in the master computer until I login into the GUI of the client system.

before the login to the GUI, I request the service status (via ssh terminal) and I get


 

$ sudo systemctl status synergy
● synergy.service - Synergy Client Daemon
   Loaded: loaded (/etc/systemd/system/synergy.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2019-05-23 12:27:58 EDT; 19s ago
 Main PID: 2728 (synergy-core)
    Tasks: 3 (limit: 4915)
   Memory: 928.0K
   CGroup: /system.slice/synergy.service
           └─2728 /usr/bin/synergy-core --client --no-daemon --debug INFO --name intelnuc1 server_computer:24800

May 23 12:27:58 intelnuc1 systemd[1]: Started Synergy Client Daemon.
May 23 12:27:58 intelnuc1 synergy-core[2728]: [2019-05-23T12:27:58] WARNING: failed to set process uid to: -1
May 23 12:27:58 intelnuc1 synergy-core[2728]: No protocol specified
May 23 12:27:58 intelnuc1 synergy-core[2728]: [2019-05-23T12:27:58] WARNING: secondary screen unavailable: unable to open screen

After I login to the GUI:

$ sudo systemctl status synergy
● synergy.service - Synergy Client Daemon
   Loaded: loaded (/etc/systemd/system/synergy.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2019-05-23 12:27:58 EDT; 4min 36s ago
 Main PID: 2728 (synergy-core)
    Tasks: 3 (limit: 4915)
   Memory: 1.5M
   CGroup: /system.slice/synergy.service
           └─2728 /usr/bin/synergy-core --client --no-daemon --debug INFO --name intelnuc1 server_computer:24800

May 23 12:31:58 intelnuc1 synergy-core[2728]: [2019-05-23T12:31:58] NOTE: started client
May 23 12:31:58 intelnuc1 synergy-core[2728]: [2019-05-23T12:31:58] NOTE: connecting to 'server_computer': 192.168.1.130:24800
May 23 12:31:58 intelnuc1 synergy-core[2728]: [2019-05-23T12:31:58] NOTE: connected to server

So if you ever get a chance to look at LightDM, I'll appreciate it.

This is my current synergy.service:

[Unit]
Description=Synergy Client Daemon
Requires=display-manager.service
After=display-manager.service
After=network.target

[Service]
User=marcelo
Group=root
Type=simple
Restart=always
RestartSec=3
ExecStartPre=/bin/bash -c "sleep 10; sudo /bin/systemctl set-environment SDDMXAUTH=$(/var/run/lightdm/root/:0)"
ExecStart=/usr/bin/synergy-core --client --no-daemon --debug INFO --name intelnuc1 server_computer:24800

[Install]
WantedBy=graphical.target

BTW, I'm using gnome in Fedora 30  with Wayland disabled.

Thank you, 

Marcelo

Edited by marcelo
Link to post
Share on other sites
Xerotope
3 minutes ago, marcelo said:

@Xerotope

This is my current synergy.service:

[Unit]
Description=Synergy Client Daemon
Requires=display-manager.service
After=display-manager.service
After=network.target

[Service]
User=marcelo
Group=root
Type=simple
Restart=always
RestartSec=3
ExecStartPre=/bin/bash -c "sleep 10; sudo /bin/systemctl set-environment SDDMXAUTH=$(/var/run/lightdm/root/:0)"
ExecStart=/usr/bin/synergy-core --client --no-daemon --debug INFO --name intelnuc1 Marcelo-s-Mac-TxWh:24800

[Install]
WantedBy=graphical.target

 

You still need to have your ExecStart line use bash to set the value of the XAUTHORITY environment variable for synergy.  Hacky, I know, but was the easiest way off the top of my head.

Link to post
Share on other sites

@Xerotope

Dean,

I missed that setting, thank you for noticing.

However, I've tried, but no success yet.

I still have to login into the GUI for the service to be able to connect to the synergy server.

I'm not an expert on this, so any help will be appreciated.

my current synergy.service is:

 

[Unit]
Description=Synergy Client Daemon
Requires=display-manager.service
After=display-manager.service
After=network.target

[Service]
;User=marcelo
;Group=root
Type=simple
Restart=always
RestartSec=3
ExecStartPre=/bin/bash -c "sleep 5;sudo /bin/systemctl set-environment SDDMXAUTH=/var/run/lightdm/marcelo/xauthority"
ExecStart=/bin/bash -c "XAUTHORITY=/var/run/lightdm/marcelo/xauthority /usr/bin/synergy-core --client --no-daemon --debug INFO --name intelnuc1 TxWh:24800"

[Install]
WantedBy=graphical.target

the status of the service before login into the GUI is:

$ sudo systemctl status synergy
● synergy.service - Synergy Client Daemon
   Loaded: loaded (/etc/systemd/system/synergy.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2019-05-23 14:48:52 EDT; 47s ago
  Process: 1347 ExecStartPre=/bin/bash -c sleep 5;sudo /bin/systemctl set-environment SDDMXAUTH=/var/run/lightdm/marcelo/xauthority (code=exited, status=0/SUCCESS)
 Main PID: 2526 (synergy-core)
    Tasks: 3 (limit: 4915)
   Memory: 3.4M
   CGroup: /system.slice/synergy.service
           └─2526 /usr/bin/synergy-core --client --no-daemon --debug INFO --name intelnuc1 TxWh:24800

May 23 14:48:47 intelnuc1 systemd[1]: Starting Synergy Client Daemon...
May 23 14:48:52 intelnuc1 sudo[2389]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/systemctl set-environment SDDMXAUTH=/var/run/lightdm/marcelo/xauthority
May 23 14:48:52 intelnuc1 sudo[2389]: pam_unix(sudo:session): session opened for user root by (uid=0)
May 23 14:48:52 intelnuc1 sudo[2389]: pam_unix(sudo:session): session closed for user root
May 23 14:48:52 intelnuc1 systemd[1]: Started Synergy Client Daemon.
May 23 14:48:52 intelnuc1 bash[2526]: [2019-05-23T14:48:52] WARNING: failed to set process uid to: -1
May 23 14:48:52 intelnuc1 bash[2526]: No protocol specified
May 23 14:48:52 intelnuc1 bash[2526]: [2019-05-23T14:48:52] WARNING: secondary screen unavailable: unable to open screen

looking at the synergy process before login in:

$ ps -elf |grep syn
4 S root      2526     1  0  80   0 -  7208 -      14:48 ?        00:00:00 /usr/bin/synergy-core --client --no-daemon --debug INFO --name intelnuc1 Marcelo-s-Mac-TxWh:24800
0 R marcelo   3280  3043  0  80   0 - 53936 -      14:50 pts/1    00:00:00 grep --color=auto syn

looking at the lightDM processes at the same time (note that there is a lightdm user):

$ ps -elf |grep light
4 S root      1118     1  0  80   0 - 60060 -      14:48 ?        00:00:00 /usr/sbin/lightdm
4 S root      1344  1118  0  80   0 - 141171 -     14:48 tty1     00:00:00 /usr/libexec/Xorg -core -noreset :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt1 -novtswitch
4 S root      1495  1118  0  80   0 - 45637 -      14:48 ?        00:00:00 lightdm --session-child 18 21
4 S lightdm   1499     1  0  80   0 -  5012 -      14:48 ?        00:00:00 /usr/lib/systemd/systemd --user
5 S lightdm   1501  1499  0  80   0 - 12986 -      14:48 ?        00:00:00 (sd-pam)
4 S lightdm   1509  1495  0  80   0 - 220549 -     14:48 ?        00:00:01 /usr/sbin/lightdm-gtk-greeter
0 S lightdm   1512  1499  0  80   0 - 69176 -      14:48 ?        00:00:00 /usr/bin/dbus-broker-launch --scope user
0 S lightdm   1513  1512  0  80   0 -  1295 -      14:48 ?        00:00:00 dbus-broker --log 4 --controller 11 --machine-id 4047399e12c94233ae08a61711b9a466 --max-bytes 100000000000000 --max-fds 25000000000000 --max-matches 5000000000
0 S lightdm   1514  1499  0  80   0 - 76275 -      14:48 ?        00:00:00 /usr/libexec/at-spi-bus-launcher
0 S lightdm   1519  1514  0  80   0 - 67078 -      14:48 ?        00:00:00 /usr/bin/dbus-broker-launch --config-file=/usr/share/defaults/at-spi2/accessibility.conf --scope user
0 S lightdm   1520  1519  0  80   0 -  1264 -      14:48 ?        00:00:00 dbus-broker --log 4 --controller 9 --machine-id 4047399e12c94233ae08a61711b9a466 --max-bytes 100000000000000 --max-fds 6400000 --max-matches 5000000000
0 S lightdm   1522  1499  0  80   0 - 40140 -      14:48 ?        00:00:00 /usr/libexec/at-spi2-registryd --use-gnome-session
0 S lightdm   1523  1499  0  80   0 - 111648 -     14:48 ?        00:00:00 /usr/libexec/gvfsd
0 S lightdm   1530  1499  0  80   0 - 78149 -      14:48 ?        00:00:00 /usr/libexec/gvfsd-fuse /run/user/976/gvfs -f -o big_writes
0 S root      1557  1118  0  80   0 -  6610 -      14:48 ?        00:00:00 lightdm --session-child 14 21
4 S root      2798  1130  0  60 -20 - 11557 -      14:48 ?        00:00:00 /usr/NX/bin/nxexec --node --user lightdm --priority realtime --mode 0 --pid 18
4 S lightdm   2810  2798  0  60 -20 - 402194 -     14:48 ?        00:00:00 /usr/NX/bin/nxnode.bin
0 S marcelo   3299  3043  0  80   0 - 53936 -      14:52 pts/1    00:00:00 grep --color=auto light

after logging into the GUI the lightdm user disappears, so I think the greeter is running under its own user:

$ ps -elf |grep light
4 S root      1118     1  0  80   0 - 60068 -      14:48 ?        00:00:00 /usr/sbin/lightdm
4 S root      1344  1118  0  80   0 - 81518 -      14:48 tty1     00:00:02 /usr/libexec/Xorg -core -noreset :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt1 -novtswitch
4 S root      3736  1118  0  80   0 - 47752 -      15:06 ?        00:00:00 lightdm --session-child 14 21
0 S marcelo   5472  3043  0  80   0 - 53936 -      15:06 pts/1    00:00:00 grep --color=auto light

the status of the synergy service after login into the GUI is :

$ sudo systemctl status synergy
● synergy.service - Synergy Client Daemon
   Loaded: loaded (/etc/systemd/system/synergy.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2019-05-23 15:23:11 EDT; 2s ago
  Process: 12045 ExecStartPre=/bin/bash -c sleep 5;sudo /bin/systemctl set-environment SDDMXAUTH=/var/run/lightdm/marcelo/xauthority (code=exited, status=0/SUCCESS)
 Main PID: 12120 (synergy-core)
    Tasks: 3 (limit: 4915)
   Memory: 2.2M
   CGroup: /system.slice/synergy.service
           └─12120 /usr/bin/synergy-core --client --no-daemon --debug INFO --name intelnuc1 TxWh:24800

May 23 15:23:05 intelnuc1 systemd[1]: Starting Synergy Client Daemon...
May 23 15:23:10 intelnuc1 sudo[12075]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/systemctl set-environment SDDMXAUTH=/var/run/lightdm/marcelo/xauthority
May 23 15:23:11 intelnuc1 sudo[12075]: pam_unix(sudo:session): session opened for user root by (uid=0)
May 23 15:23:11 intelnuc1 sudo[12075]: pam_unix(sudo:session): session closed for user root
May 23 15:23:11 intelnuc1 systemd[1]: Started Synergy Client Daemon.
May 23 15:23:11 intelnuc1 bash[12120]: [2019-05-23T15:23:11] WARNING: failed to set process uid to: -1
May 23 15:23:11 intelnuc1 bash[12120]: [2019-05-23T15:23:11] NOTE: started client
May 23 15:23:11 intelnuc1 bash[12120]: [2019-05-23T15:23:11] NOTE: connecting to 'Marcelo-s-Mac-TxWh': 192.168.1.130:24800
May 23 15:23:11 intelnuc1 bash[12120]: [2019-05-23T15:23:11] NOTE: connected to server

under the /var/run/lightdm there are:

/var/run/lightdm/root/:0
/var/run/lightdm/marcelo/xauthority
/var/run/lightdm/lightdm/xauthority

Not sure which one to use. Or if I need the ExecStartPre if I'm setting the XAUTHORITY in the ExecStart
Not sure either what user and group should I use for the service  (I commented that out for the time being)

Marcelo

 

Link to post
Share on other sites
Xerotope
9 minutes ago, marcelo said:

 

[Unit]
Description=Synergy Client Daemon
Requires=display-manager.service
After=display-manager.service
After=network.target

[Service]
;User=marcelo
;Group=root
Type=simple
Restart=always
RestartSec=3
ExecStartPre=/bin/bash -c "sleep 5;sudo /bin/systemctl set-environment SDDMXAUTH=/var/run/lightdm/marcelo/xauthority"
ExecStart=/bin/bash -c "XAUTHORITY=/var/run/lightdm/marcelo/xauthority /usr/bin/synergy-core --client --no-daemon --debug INFO --name intelnuc1 TxWh:24800"

[Install]
WantedBy=graphical.target

Now it looks like you're using your user account's xauthority file instead of the root one?  That won't exist before login which might explain things.

 

 

Link to post
Share on other sites
Xerotope

I had a few moments to install LightDM and confirmed it worked on my end too.  For completeness, here's my working synergy.service file:

[Unit]
Description=Synergy Service
Requires=display-manager.service
After=display-manager.service

[Service]
Type=simple
Restart=always
RestartSec=3
ExecStartPre=/bin/bash -c "sleep 10; /bin/systemctl set-environment LIGHTDMXAUTH=/var/run/lightdm/root/:0"
ExecStart=/bin/bash -c "XAUTHORITY=${LIGHTDMXAUTH} /opt/synergy-core/build/bin/synergyc -f -n minotaur 192.168.0.150"


[Install]
WantedBy=graphical.target

If anyone has a general way of finding the XAuthority file for multiple window managers, It'd be nice to see.

 

Glad its working for you, @marcelo!

Link to post
Share on other sites

In my case, I also removed the ExceStart statement.

It takes a little while until it starts working, but it works so my ExecStart looks like this:

ExecStart=/bin/bash -c "XAUTHORITY=/var/run/lightdm/root/:0 /usr/bin/synergy-core --client --no-daemon --debug INFO --name mynuc TxWh:24800"

 

Earlier in this thread, I saw that someone did

Environment="XAUTHORITY=/var/run/lightdm/root/:0"

after the ExecStart instead of executing a shell to run the service executable.

I have not tried that

Link to post
Share on other sites
Xerotope
12 minutes ago, marcelo said:

Earlier in this thread, I saw that someone did

Environment="XAUTHORITY=/var/run/lightdm/root/:0"

after the ExecStart instead of executing a shell to run the service executable.

I have not tried that

I gave it a try, and it looks like it works!  (I was worried about overloading XAUTHORITY more globally).  Much cleaner than going through bash.

Link to post
Share on other sites
  • 10 months later...
xavierbaez

Hello.

I tried all available answers.

If I execute the ExecStart command directly, it works!
if I execute the command through systemctl start synergy.service, it does NOT work

Ended up copying the desktop file to the with ~/.config/autostart/ 

folder

Anybody would have an idea why that happened?

Link to post
Share on other sites
  • 8 months later...
  • 2 months later...
  • 4 months later...
S Sauve

Three years and no progress on this from Symless?  How many dev hours do you need to make this happen?  Ever considered a subscription service to help pay to implement continuous improvement?

Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...