Web Development & Execution
David Addison
by David Addison
share this
?fl
« Back to the Blog

Using the same keyboard and mouse for both your PC and Mac

06/17/2010
Using the same keyboard and mouse for both your PC and Mac

Are you one of those developers that has both a PC and a Mac, and you have a mouse and possibly a keyboard for both? Perhaps you use a Keyboard Video Mouse switch (KVM) to switch between computers. Maybe you don't have a Mac, but you have two or three PCs. Regardless of your situation this article is for you. I am going to explain step by step how to setup Synergy, a software based KM (Knowledge Management) sharing application that distributes information via your LAN (local area network).

History
According to the Synergy website their first incarnation was called CosmoSynergy, first developed in 1996 at SGI. The need for such a program came about because most developers at SGI had both an IRIX and a Windows box on their desks and they were not happy with the switchboxes available at the time. The current version of Synergy is written from scratch and does not use any CosmoSynergy code. Synergy uses a client/server infrastructure. I am going to demonstrate setting up a server on my Windows box with Mac as the client. Windows is version 7, Mac is OSX 10.6.3. The current version of Synergy is 1.3.1.

First, download and install Synergy for Windows from their website:
http://synergy2.sourceforge.net/

Next, run the installation executable. You should see the configuration window. Make sure the radio button for "Share this computer's keyboard and mouse" is selected.

Click "Configure" in this same section.

Under the "Screens" section add references to the hostnames that your computers will resolve to on the network. There are many ways to do this depending on your network infrastructure. For my network setup my PC has a static IP address. I edited my hosts file to make sure that "pwelchpc" resolves to the proper IP address. For testing I also assigned a static IP address to the Mac and assigned it a hostname in my PC's host file. However, since the Mac is actually a Macbook it needs to be mobile so I reverted it back to DHCP and it works fine as long as you use the proper hostname (you can type "hostname" in the terminal to find the hostname). Click here to read instructions about how to edit your hosts file.

If you have any problems getting your computer hostnames to resolve the best way to troubleshoot is to ping them. In Windows you use Start >> CMD >> then type "ping hostname." You replace "hostname" with the hostname of the computer. On OSX you use Applications >> Terminal >> and type: "ping hostname". If you are having trouble getting Synergy to work this should be the first diagnostic you try. On Windows you issue the command "ipconfig /all" to get your IP address. On OSX via the terminal you can issue the command "ifconfig."

After you add the screens you need, add the "links" which explain to Synergy how they are arranged. My PC is to the left of my Mac so my first entry looks like:

---
0 to 100% of the left of PwelchMacs-Macbook-Pro.local goes to 0 to 100% of pwelchpc
---

After you hit the plus mark to add the link you should see a new entry that says something like: "pwelchpc is left of PWelchMacs-MacBook-Pro.local." Now repeat this the other way around so that Synergy knows what is on the right.

---
0 to 100% of the right of pwelchpc goes to 0 to 100% of PWelchMacs-Macbook-Pro.local
---

Next click on the "Test" button on the main configuration window which opens a Synergy Server console window. This will allow you to diganose when your clients try to connect or any issues you may be having while running Synergy.

Next we install the Mac client. On your Mac downlod the Synergy OSX files-these come packaged at .tar.gz file. If you browse this file you will see a doc folder, a few text files, and two executables. You can copy these executable files anywhere. I copied mine to /applications/utilities/synergy.

Now it is time to get jiggy with the terminal. Just like the PC we need to set the hostname for the server (the PC). Open the terminal and perform the following commands (items in brackets are comments to you):

sudo vi /private/etc/hosts

[Enter your password.]

[Hit the 'i' key. This drops you into interactive mode which lets you edit the file.]

[Scroll to the bottom of the file and add a new line. Replace 127.0.0.1 with the IP address of your server, and "serverhostname" with the hostname of your Synergy server. Please note that these items are seperated by a tab character NOT a space]

127.0.0.1 serverhostname

[Hit the Escape key]

:wq [enter]

dscacheutil -flushcache

Ok, now you are all done and ready to run Synergy. On the PC make sure that the test server is running. On the Mac issue the terminal command (the command will vary depending on where you placed your Synergy binary files):

/applications/utilities/synergyc serverhostname

This starts the synergy client (synergyc) and tells it to connect to serverhostname. Synergy will run in the background so you can close the terminal window if you would like. From time to time Synergy may stop working. You may have to restart both the server and client. On Windows you can go to your taskbar and right click to exit. On OSX bring up the terminal. You can issue the command "killall synergyc." Or you can issue these commands:

ps ax | grep synergyc

[the first number returned in the sequence is the pid, or process ID]

kill -9 [pid]

And thats it. You should now be able to use the same mouse and keyboard on both your PC and Mac, and you should even be able to copy and paste! Synergy also works for Linux. Please note that I have been using Synergy for years and I am familiar with setups that get much more complicated than this (think three computers with multiple monitors per computer). Synergy is not easy to configure, so hang in there and keep troubleshooting if it does not work for you. Please send in your comments regarding your own Synergy experience.

Thanks!

Thank you for contacting us!

We'll be in touch!

Back Home ×