Synergy: One keyboard (and mouse) to rule them all

293

Author: Joe 'Zonker' Brockmeier

If you’re one of the many users who has two (or more) computers on your desk, you might get tired of switching between the keyboard and mouse on different systems. KVMs are one solution, but if you’d like to save a few bucks and be able to switch between two or more computers with a flick of the mouse, Synergy is the software for you.

Synergy allows you to use a single keyboard and mouse to control multiple computers running Linux, Mac OS X, Windows, and other operating systems. It also allows you to share clipboards between computers, so you can select text in a program on Linux, and paste it into an application in Windows. Best of all, Synergy is freely available under the GNU General Public License (GPL).

Setting up Synergy

To start, grab Synergy packages or source code for your platforms of choice. Binaries are available for Linux (as RPMs), Mac OS X, and Windows. Install Synergy on all of the systems where you want to share a keyboard and mouse.

If you’re using Debian or Ubuntu, you can install Synergy using apt-get install synergy. One word of caution, though — Debian Sarge and Ubuntu Breezy have packages based on the 1.2 series, and Debian Etch and Ubuntu Dapper have packages based on the 1.3 series. The protocols for 1.2 and 1.3 are incompatible. If you want to use Synergy with Dapper and Breezy, you’ll need to compile Synergy 1.3.1 from source.

After you’ve installed Synergy in a manner befitting your favorite operating systems, it’s time to configure Synergy. You’ll need to create a file called ~/.synergy.conf, or /etc/synergy.conf if you want a system-wide configuration.

Here’s a sample synergy.conf file:

# This section defines the hosts.
section: screens
      host1:
      host2:
          super = meta
end

# This section defines the relationships between the hosts.
section: links
      host1:
	    right = host2
      host2:
	    left  = host1
end

section: options
      switchDelay = 1000

Synergy alternatives

Synergy isn’t the only way to control several desktops using a single keyboard and mouse, and it has its advantages and disadvantages. For example, if you want to control a computer that’s not running a GUI, then Synergy isn’t an option and you should probably look at buying a KVM switch. Also, Synergy doesn’t provide a way to actually share a monitor, though the developers say they’re looking into this, so if you’re looking to save on costs by sharing hardware, a KVM again might be a good option.

The downside to using a KVM switch, however, is that most KVMs require you to use either USB or PS/2 equipment. You can’t mix and match, which is something of a pain if you are using a PC with a PS/2 keyboard and mouse alongside a PC or Mac with USB keyboard and mouse. Also, you need to use a hotkey sequence to switch between computers, rather than just moving the mouse to the edge of the screen and rolling over to the next screen. Also, KVMs for sharing two or four systems can be reasonably priced, but switches for sharing more than four systems get pretty expensive. Finally, if I’m actively working between two computers, I don’t want to share a monitor between them — I’d like to be able to eyeball the screen for my test system while I’m typing on the other, so sharing a monitor via a KVM isn’t such a wonderful feature for me.

Another option is x2vnc, which is slightly easier to set up than Synergy, but suffers from poor performance, and does not share a clipboard between systems. Also, x2vnc is limited to two computers, so if you want to control three or four computers, you’re out of luck.

The advantage to x2vnc is that it should work with any system that can run a VNC server, so you could use x2vnc with a Linux system any system that can run a VNC server. Synergy is limited to Unix-type OSes, Windows, and recent versions of Mac OS X.

If you’re using two X-based systems, x2x is also an option. Again, x2x is limited to two systems.

The first section includes all of the hosts that will be connected using Synergy. The option under host2 indicates that when the Super key (usually the “Win” key) is pressed on the keyboard, it will be sent to the client as the meta key. See the list of key names for the entire list of remappable keys.

The next section maps the relationships between the hosts. In this example, when I move the mouse to the right edge of the screen on host1, it will roll over to host2, and back to host1 after I move the mouse to the edge of the screen on host2. You can also map screens “up” or “down.” You do need to explicitly define the relationships for both hosts — i.e., saying host2 is to right of host1 doesn’t mean that Synergy will assume host1 is to the left of host2.

The options section is, well, optional. I like the switchDelay option, which tells the Synergy server to wait a short period of time before sending the mouse and keyboard input to the other system when the mouse is on the edge of the screen. The time is measured in milliseconds, so you’ll probably want to set it to at least 1000.

You can read about the configuration options on the Synergy Web site, or read the synergys man page. Note that you don’t need a configuration on the client computers — just the server.

Running Synergy

After you’ve set up the configuration file on the host that will be the Synergy server, start Synergy and see how it works. First, fire up the server with synergys -f. This will start the server in the foreground (-f), which will allow you to eyeball Synergy’s event messages. You’ll want to do that the first time (at least) so you can see any error messages that you might have.

Next, start the Synergy client on your other machines, using synergyc -f hostname, with hostname being the hostname of the Synergy server.

If you didn’t get any errors, you should now be able to move the mouse to the corner of the screen and have it roll over to the next system, and use the other system normally with the Synergy server’s keyboard and mouse.

After you’ve gotten Synergy working well, you can drop the -f option from synergys and synergyc, and it will run quietly in daemon mode. If you’d like to start Synergy automatically, see the docs on the Synergy site.