Synergy is a very useful piece of software for anybody wanting to share a mouse and keyboard between two networked computers.

Here is the setup I use to:

  • encrypt the key presses sent over the network from the synergy client to the server and
  • automatically restart the synergy client when it crashes.

First of all, I've got the following ~/.synergy.conf on both of my laptop and desktop machines:

section: screens  
section: links  
  right = mydesktop  
  left = mylaptop  
section: options  
keystroke(alt+shift+space) = switchInDirection(left)  
keystroke(alt+space) = switchInDirection(right)  

With this, I am ready to start the server on my desktop machine:

synergys -a localhost

Now, in order to encrypt the synergy client/server traffic, I create an ssh tunnel between the two machines:

ssh -f -N -L localhost:24800:localhost:24800 mydesktop

Then I start the synergy client on my laptop. However, some recent problems have convinced me to have a more robust alternative to simply starting the client like this:

synergyc localhost

As recommended by a few helpful people on #debian-devel, I decided to use the supervise tool (part of the daemontools package) to automatically restart the synergy client if it crashes. Here is how I do it:

supervise ~/.synergyc &

This command refers to a ~/.synergyc directory containing a single run script. That shell script consists of:

xset r rate 500 30  
/usr/bin/synergyc --no-daemon localhost

(The xset call is necessary since synergyc crashes seem to reset the repeat flag of X for some reason...)

The only problem I still need to fix in my setup is the potential password leak in the next few seconds after the synergy client crashes. Such a crash has already caused me to accidentally type my laptop password into a desktop IRC window the other day :(

Ideally, I would like the synergy server to swallow the first second or two of keyboard input after its client suddenly drops out. This could eliminate quite a few embarrassing wrong windows.