Chris vs. Synergy

My HTPC setup was less than ideal, seeing how it was basically a mini tower stuffed in a desk by the TV, so I decided to move the system into my wall unit proper. To do this, the first thing I needed a smaller case for the PC. After a lot of research, I decided on the Antec Fusion Black.

It’s a really nice case. It runs quiet and cool and it looks like an everyday receiver, not a PC, which is exactly what I wanted. One thing though, the front LCD display is horrendous. I recommend just leaving it turned off. It’s very washed out, has slow refresh rate, and IMO there’s no need to look that the front to the PC to see the name of the movie you’re playing.

My mouse and keyboard are a Logitech G7 and an Apple Wireless Keyboard. I installed the USB dongles for RF and Bluetooth inside the case thanks to a couple of USB 4-pin to female adapters.

After setting up the keyboard and mouse on the coffee table, I realized why I rarely use the HTPC — it’s just so counter intuitive to a have a KB/M out all the time, especially when my MacBook Pro is always out anyway. Waitaminute!

Enter Synergy. What is Synergy? It’s is a really neat application that allows you to share a keyboard and mouse across multiple devices. It’s sort of the same concept of a KV/M but turned upside-down, not to mention not as clumsy or expensive, not to mention to toggle switch! With Synergy you install the software, do a simple *cough*BS*cough* config, and you’re sharing your keyboard and mouse between systems.

Ok, setup was not so easy. On client side, the PC, I’m running Windows 7 Ultimate x64. I installed the latest stable release of Synergy thinking that was my best bet, but I was wrong. The problem is Synergy needs to run as administrator or when an UAC prompt pops out you lose control of the keyboard and mouse.

The solution was to install the latest beta (I grabbed 1.4.1) for Windows and have it run as a service. This way Synergy has the privileges to interact with UAC prompts and you don’t need to keep a keyboard under the couch for UAC prompts alone.

The server side, the Mac, was a lot harder to configure. The server runs as a daemon, meaning there’s no UI, so config is an under-the-hood experience. There is a product called SynergyKM which has a UI configuration, but based on my evaluation it would not fit my needs. Time to roll up my sleeves.

I used MacPorts to install the Synergy binaries:

chris@macbookpro:~$ sudo port install synergy

If you don’t have MacPorts you can install Synergy by by downloading it from the web site. The current MacPorts version is a few point releases behind, but that’s not a problem for me.

My config is fairly straight-forward with a couple of exceptions. I treat the PC as being to the right of the MacBook. That means when I move my mouse to the right of the screen it appears on the PC. I wanted control-click to act like a right mouse button click as it does on the Mac and Command to act as Control on the PC. That way I don’t have to Command-C to copy on the Mac and Control-V to paste on the PC, I can just use Command for everything. Finally, I wanted Option-Command-Plus and Option-Command-Minus to zoom the screen via Windows Magnifier (it’s hard to see tiny text from six feet away).

Here’s my config file, which I store in ~/.synergy/synergy.conf

 section: screens
    macbookpro:
    monster:
        super = alt
        alt = ctrl
        meta = super
 end
 section: aliases
    macbookpro: 
        macbookpro.local
 end
 section: links
    macbookpro:
        right = monster
    monster:
        left = macbookpro.local
 end
 section: options
    mousebutton(control+1) = mousebutton(3)
    keystroke(super+alt+Plus) = keystroke(meta+Plus)
    keystroke(super+alt+Minus) = keystroke(meta+Minus)
 end

Section by section. “screens” defines the system. “monster” is my PC and obviously “macbookpro” is the Mac.

The block…

    super = alt
    alt = ctrl
    meta = super

…is where I map the keys for Command and Option. The names are misleading in Synergy. On the Mac side, “super” is the Option key, “alt” is the Command key and “ctrl” is control. There is no “meta” key. Why that’s in the config will be explained later.

“aliases” simply maps the OS X name for the host to a more friendly format:

     section: aliases
        macbookpro: 
            macbookpro.local
     end

“links” is a straight-forward section:

    macbookpro:
        right = monster
    monster:
        left = macbookpro

Here the Mac is treated as the left screen, PC is on the right.

Finally, “options”:

     section: options
        mousebutton(control+1) = mousebutton(3)
        keystroke(super+alt+Plus) = keystroke(meta+Plus)
        keystroke(super+alt+Minus) = keystroke(meta+Minus)
     end

The first directive maps Control + Click to the right mouse button on the PC. The next two define Option + Command + (Plus | Minus) to the zoom commands on Windows 7 (Windows Key + [Plus | Minus]). If you remember from before “meta” on the Mac maps to “Super” on the PC, which is the Windows key, so we define a faux mapping for “meta” to do this. Yes, it is as confusing as it reads.

Now if you run the synergy server from the terminal, you can test it out:

chris@macbookpro:~$ synergys -f --config ~/.synergy/synergy.conf

If that command does not bomb out you’re in good shape, so far.

Now to get Synergy to run when you log in is a challenge. This is accomplished through launchd.

I created the following file as ~/Library/LaunchAgents/net.sourceforge.synergy2.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" 
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>Label</key>
        <string>net.sourceforge.synergy2</string>
        <key>ProgramArguments</key>
        <array>
            <string>/Users/chris/bin/synergy.sh</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
    </dict>
</plist>

This will launch a shell script in my local bin directory at login. For me the script is ~/bin/synergy.sh. The contents are:

#! /bin/sh
 
SYNERGYS=/opt/local/bin/synergys
CONFIG=/Users/chris/.synergy/synergy.conf
 
if ! ps axco command | grep -q "^synergys\$"
then    
    $SYNERGYS --daemon --config $CONFIG
 
    if [ $? -ne 0 ]
    then
        echo "synergys failed to load."
    fi
 
else
    echo "synergys already loaded."
fi

This script looks to see if the Synergy server is running, if not it will launch it. Pretty simple.

That’s about it. If anything fails be sure to check Console (Command-Space and type “Console”).

One very cool thing is the multi-touch commands are at a very low level of the OS, so two-finger scroll etc. will all work on the Windows side just as it does on the Mac.

Related Posts:

  • http://catadoc.com/readme-65.htm Readme | Catadoc.com

    [...] readme.blog » Blog Archive » Chris vs. Synergy [...]

blog comments powered by Disqus