3 May 2007

How to Use Synergy on Two Ubuntu Boxes

Filed under: Computers,Cool Stuff

Synergy lets you easily share a single mouse and keyboard between two or more computers, with two or more monitors, without hardware.

Redirecting the mouse and keyboard from one machine to the other is as easy as moving the mouse off the edge of your screen towards the other monitor. Synergy also merges the clipboards of all the systems into one, allowing cut-and-paste between systems.

In this example, we’ll be setting Synergy up to control two Ubuntu Linux machines. However, these instructions are not distribution specific and should work on any system that has Gnome installed with just a little tweaking. It looks complicated, but it’s actually not.

We already know you’re smart, you use Linux, you can do it!

First you’ll need to download the Synergy program to both of the machines you want to control. You can get it from the Ubuntu repositories using Synaptic (recommended for Ubuntu users) or download it from SourceForge here. (If you’re downloading from SourceForge, either install the RPM, for you Slackware-types, or expand the tarball someplace you can find it and install it).

Now that we have it installed, you need to decide which machine you want to be the server and which you want to be the client. Once you’ve done that, we’re half-way there!

This is the tricky part, but follow closely and everything will work just fine.

Create a new text document called synergy.conf. Put it someplace out of the way, because after we’re done here you won’t be needing it again, but will have to know where it is.

In this synergy.conf document we’re going to tell synergy the names of the computers we want to control and what the screen layout is of those computers. Here is an example of my synergy.conf file:

section: screens
josie:
batman:
end
section: links
josie:
right = batman
batman:
left = josie
end

Josie is the hostname of my main Ubuntu box, Batman is the hostname of my other machine. Josie’s monitor is to the left of Batman’s monitor, Batman’s monitor is to right of Josie’s. So what we’re saying in this synergy.conf file is that when the mouse gets to the right of Josie’s monitor, it appears on Batman. And when the mouse gets to the left of Batman’s monitor, it appears on Josie. That simple.

So write your file with your computer’s hostnames and their positions relative to each other. When you’re done, save the file and close it.

Now, we’re going to test how everything works.

On the machine that is going to be the server (in my case Josie), open a terminal window and type:

synergys -f – -config /path/to/your/synergy.conf

What we’ve done here is launch Synergy in server mode on the server machine. The -f parameter tells Synergy to run in the foreground so we can see if everything works. If all is well you’ll see Synergy fire up and report that it has started the server. If there is an error, it will display here what is the problem. Most of the time it’s because Synergy can’t find the synergy.conf file, so be sure you entered the path correctly.

Now, on your client machine (in my case Batman) open a terminal window and type:

synergyc -f serverhostname

Where serverhostname is your server’s host name.

Again, we’ve launched Synergy, and told it to look to the server machine (in my case Josie) for the synergy.conf file. We’ve also told it to run in the foreground again to make sure we haven’t experienced any errors.

Now, if all has gone well, you should be able to move the mouse on the server from one monitor to the other, and once the mouse cursor is on the other monitor, use the server’s keyboard on the client.

Once you’ve got everything up and running to your satisfaction, quit both Synergy processes by hitting CTRL-C in the terminal window on both machines.

To have Synergy run at startup (which is the logical thing to do) we’re going to place some additions into the Startup programs in the Sessions menu.

On the server machine select System > Preferences > Sessions and click on the Startup Programs tab. Click the New button and type Synergy into the Name box and type:

synergys – -config /path/to/your/synergy.conf

into the Command box. When you’re finished, click OK.

On the client machine select System > Preferences > Sessions and click on the Startup Programs tab. Click the New button and type Synergy into the Name box and type:

synergyc -serverhostname

(where serverhostname is your server’s host name) into the Command box. When you’re finished, click OK.

Restart Gnome on both machines however you’d like, I prefer CTRL-ALT-Backspace, and you’ll be able to only have one keyboard and mouse on your desk.

HORRAY!

If you run into trouble, check out the troubleshooting FAQ on the Synergy home page here.

3 Responses to “How to Use Synergy on Two Ubuntu Boxes”

  1. dhardy says:

    Hey man I got this up and running and it is awesome! The only thing that didn’t work exactly right was launching the client. To remedy the situation I simply substituted the Synergy server IP for the hostname. I am not sure why this is the only thing that I had to modify. None the less, great article it helped tons.

  2. jonreily says:

    This is a good point, thanks for pointing it out!

    IPs will work just as well as hostnames, but if you prefer to use a hostname (DHCP over your home LAN for instance) make sure that your hostname is entered in the Network Settings (System > Administration > Network Settings) and that Automatic Service Discovery is set to on.

    Jon

  3. […] had such a great response from my Synergy on Two Ubuntu boxes post I’ve decided to make one for those of out there who want to use Synergy on an Ubuntu box […]

Leave a Reply