First, a brief history of why do this…
I have two computers in my desk and having two sets of keyboards and mice takes too much space on top of that, sometimes I found myself typing in the wrong keyboard which could be problematic. Thus having one set of peripherals and a way to use them in both computers is something I find useful. Enter Synergy.
Why Synergy and not a (hardware) KVM?
For starters, Synergy used to be a completely free project and very easy to install under GNU/Linux most of the time, the configuration was/is a proper UNIX™ like using text files and in general was easy to find, setup and use. Nowadays Synergy is not easy to get since (still a FLOSS project) its developers have decided to charge one time US$5 fee, paying this fee (supposedly) makes very easy to obtain it and allows its development to keep going but if you don’t want/like to pay for it1 developers encourage you to either compile it or grab a nightly build2 and basically as with many FLOSS projects you read or investigate until you make it work on your environment.
With a (hardware) KVM one must start by picking the right model, if available buy it, then we need to accommodate space for it in our desk/environment, then you need to setup the cables and at some point you need to use the other computer you need to press a button to make the change this every time you go back and forth. These are in my opinion too many disadvantages, but of course things like keyboard configuration per OS work (Alt-Gr works!) as expected.
Still for now I prefer using Synergy and here’s how to compile it.
Pre-requisites
The following must be present on the OS X system and properly configured:
- Homebrew, install it by following the instructions on brew.sh
- CMake, install it with
brew install cmake
- Git, install it with
brew install git
- Qt, install it with
brew install qt
. Add the following links so Qt has no problem finding its requirements:
$ cd /Library/Frameworks/
$ sudo ln -s /usr/local/Cellar/qt/4.8.6/lib/QtCore.framework/
$ sudo ln -s /usr/local/Cellar/qt/4.8.6/lib/QtGui.framework/
$ sudo ln -s /usr/local/Cellar/qt/4.8.6/lib/QtNetwork.framework/
- Xcode, get it from AppStore or from here
- Make sure the
/Developer
directory exist and inside this directory the following links must be present:
$ cd /Developer/
$ ls -lrt
total 16
drwxrwxr-x 3 root admin 102 Jan 15 2014 Extras
drwxrwxr-x 3 root admin 102 Jan 15 2014 Documentation
drwxrwxr-x 4 root admin 136 Jan 15 2014 Applications
lrwxr-xr-x 1 al3man1 admin 76 Nov 4 14:36 Library -> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Library
lrwxr-xr-x 1 al3man1 admin 73 Nov 4 14:37 SDKs -> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/SDKs
Otherwise create them:
$ cd /Developer/
ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Library
ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/SDKs
Next, we clone the repository
From Github:
$ git clone https://github.com/synergy/synergy.git
Cloning into 'synergy'...
remote: Counting objects: 15034, done.
remote: Compressing objects: 100% (4043/4043), done.
remote: Total 15034 (delta 11872), reused 13702 (delta 10812)
Receiving objects: 100% (15034/15034), 47.99 MiB | 1.31 MiB/s, done.
Resolving deltas: 100% (11872/11872), done.
Checking connectivity... done.
Then we start the compilation
I had better results using the Xcode as the CMake generator, you can check the ones you have installed by issuing the command hm genlist
from the root directory of the recently cloned repository, then in the following step you can use the number specific to your preferred generator3.
Go into your project directory and type:
$ ./hm.sh genlist
1: Unix Makefiles
2: Xcode
3: Eclipse CDT4 - Unix Makefiles
You will see that in this case Xcode
is number 2 which is the one we are going to use.
Let´s configure
Issue the following command in your terminal:
$ ./hm.sh conf -g2 --mac-sdk 10.10 --mac-identity `hostname`
The -g2
parameter is pointing to the generator to use in this case is Xcode
.
You can change the bit of hostname
to anything you like, as is it should translate to your computer hostname.
If no errors are detected you may continue with the next step.
Let´s build the app
Running the following command will start the build of the app:
$ ./hm.sh build
Hopefully you won’t run into troubles following these steps. At the end you can find the app inside the bin
folder of your project.
Happy hacking!
Edit 1:
My actual configuration involves an OS X machine (server) and a GNU/Linux machine (client) I was a lot disappointed that Alt-gr did not behave correctly in the client machine so much that I was in the process to buy a KVM switch since without this key I can not really access to many symbols required in the CLI (@, \, |, etc.) I even created and script to display these symbols so I can copy/paste when needed, this was getting on my way so much that I was relaying in Ctrl-r to load past commands and then modify them but sometimes it was not enough. Today I decided after publishing this post that I would try to fix the Alt-gr issue and I am happy to say that I found a solution after reading and looking to several bug reports and discussing the issue on IRC finally some light! In summary, I updated the GNU/Linux machine to the latest Synergy version at the moment 1.6.3 (it was running version 1.4.x) and in the server machine (that is running 1.6.1) I created a configuration file instead of using the default of the Synergy GUI I opted for using the exported configuration file and added a line:
alt = altgr
This line was added to the section screens
in this case for the client (Linux machine) restarted the server and everything worked out! If helps I am using a QWERTZ (German) keyboard and now works properly on both systems. The full configuration of this specific section is as follows:
section: screens
linux_client:
halfDuplexCapsLock = false
halfDuplexNumLock = false
halfDuplexScrollLock = false
xtestIsXineramaUnaware = false
switchCorners = none
switchCornerSize = 0
alt = altgr
osx_server:
halfDuplexCapsLock = false
halfDuplexNumLock = false
halfDuplexScrollLock = false
xtestIsXineramaUnaware = false
switchCorners = none
switchCornerSize = 0
end
Edit 2:
Of course the “fix” for the Alt-gr key breaks the Alt key… which in my case is sad, I am running Awesome WM and movements and other stuff requires this key, I will have to remap it or really get a KVM switch for now I don’t see any other solutions.
- Synergy is very useful yes! But to pay for it I will need e.g. that the Alt-gr key behaves properly between OS X and GNU/Linux, there are many other glitches but this is in the top of my list. ↩
- Here, if you don’t want to compile: http://synergy-project.org/nightly ↩
- In my case 2 is -g2 passed as argument in the command line ↩