Can the Synergy client be configured to connect to one of many servers?

I have a laptop that I use at home and at the office. I also have desktop computers (with attached keyboards and mice) set up at both locations. Both desktops are set up as Synergy servers so that I can share their input devices with the laptop.

When I arrive at either location I need to reconfigure the laptop to connect to the desktop at that location. This always involves changing the IP address that the laptop tries to connect to.

It would be particularly useful if I could just enter a list of server addresses in the client configuration and have the client attempt a connection to any one of those addresses if it is discovered on the network.

If this isn't possible, is there another way I can configure my setup so that I don't have to keep manually adjusting the configuration when I relocate my laptop?

Thanks!


Solution 1:

(not very secure and robust, but a working start): using shell,

for i in work-server01 home-server01; do
    ping -c 1 "$i" && syngergyc "$i"
done

You could do something similar in in cygwin or in a bat file if you are running windows. The idea would be: have your computer look for the host, and connect to it if if can find it.

(edit) You'd want to run this explicitly, not have it running in the background. You don't want to walk into a coffeeshop or an airport and have some lucky malignant stranger take your lappy as a client.

Solution 2:

I know this is an old post but I ended up writing a little bash script to handle this one for me, it essentially loops over your IP's until one with an active synergy port is available then it attempts to connect with the --no-restart flag so if the connection is reset it can restart the process.

Gist here: https://gist.github.com/CrashyBang/c2d910f9e495f4506916e12cf2b6051d

Or code here:

#!/bin/bash

# IP address to cycle through (in order of priority)
ip=( "192.168.20.102" "192.168.20.103" )

# Check if synergy is already connected
if pgrep "synergyc"; then
  # Synergy already connected
  echo "Synergy is already running."
 else
   # Loop over ip's
   for i in "${ip[@]}"
   do
     # Ping ip with default synergy port
     nc -z "$i" 24800
     if [ "$?" -eq 0 ]; then
       # Connect synergy if ip available and synergy port active
       /usr/bin/synergyc --no-restart -n media -f "$i"
       # Use no-restart so if connection is cut synergy stops.
     fi
   done
 fi

I run it on a 15 second cron like so:

* * * * * /usr/local/bin/synergy-client
* * * * * sleep 15 ; /usr/local/bin/synergy-client

It's great in the sense that I can connect my first server laptop then disconnect power up my second server laptop and it will automatically connect without having to do anything to the client computer.

Solution 3:

I did something similar, just in Windows. This is a powershell script

$servers = "192.168.101.70","192.168.1.148"
While (1) { 
    Foreach($s in $servers) { 
        If (Test-Connection -Cn $s -BufferSize 16 -Count 1 -ea 0 -quie) { 
            Write-Host "$s is on line"
            $Params = @{FilePath='C:\Program Files\Synergy\synergyc.exe'
                    ArgumentList=@('--enable-crypto','--tls-cert','C:\Users\vissie\AppData\Local\Synergy/SSL/Synergy.pem','--no-restart',$s)
                    Wait=$True
                    NoNewWindow=$True}
        Start-Process @Params
        Write-Host "App stopped...."
        } Else {
        Write-Host "$s is offline"
        }
    }
}