Run Synergy Automatically during login on a Mac

Synergy is a great program that let’s you share one keyboard and mouse across multiple computers. I’m using it to connect a mac to a PC.

I wanted the synergy server to be running on my mac automatically every time I login. This feature is a button-click in the gui version on the PC but there are some more involved instructions on the official site for accomplishing this on a mac but it required using a login hook (which I didn’t want to do). After some experimentation, here’s an alternative that uses a shell script, and an automator script to get the job done.

First, make a file called run_synergy.command and customize it to launch synergy with your arguments:


#!/bin/sh
prog=(/Applications/synergy/synergy-1.3.1/synergys -c /Applications/synergy/synergy-1.3.1/synergy.conf)

### Stop any currently running Synergy client
killall ${prog[0]##*/} >> /Applications/synergy/error_log 2>&1

### Start the new client
exec "${prog[@]}" >> /Applications/synergy/error_log 2>&1

As you can probably see, that will restart the server for you, keeping a log of what it’s doing in case you need to do some debugging.

Next, create a new workflow with Automator. The workflow will only have one item called “Run Shell Script” and it will simply point to the run_synergy.command file you’ve just created. Save that Automator script as an Application called “run_synergy”.

The final step is to visit Preferences->Accounts->Login Items and add the run_synergy Automator script you just created to the list.

You can [download the run_synergy automator application and script 123k zip. The download contains these files as I’ve described above if you’d rather not go through the steps yourself. Simply install both in /Applications/synergy/ and adjust the file run_synergy.command to taste. Enjoy.


Comments

6 responses to “Run Synergy Automatically during login on a Mac”

  1. When I use the automator application, I see the icon in my dock only while the program is launching and then it disappears automatically. I wonder if it’s something in the config file for synergy that makes it run in the background or if it’s just a difference between the two different versions of the OS (Works for me in Leopard and Snow Leopard).

    Let me know if you discover the solution.

  2. Lori Martin-Friedel

    This was handy, especially since my loginhook for synergy stopped working after I updated to Leopard. I know nothing about automator though. I see this leaves an icon for the running app in my Dock. Any way to run this completely invisibly in the background and not have a Dock icon show up?

  3. Thanks! This is exactly what I was looking for. At least on Snow Leopard, I don’t get the Automator icon in my dock after launching run_synergy.

  4. Thanks, just what I was looking for.
    You might want to add that I had to chmod run_synergy.command (chmod 755 run_synergy.command).
    Thanks,
    James

  5. I love synergy, using it for all of my machines now, even the iPad works:

    http://modmyi.com/forums/iphone-news/716935-synergy-ipad-share-your-mouse-keyboard.html

    Thanks,

    Tyler
    Senior Photographer

  6. This is great! Thanks!

    I know this post is old, but if you add >/dev/null 2>&1 & to the end of the Automator path, the application will automatically quit after launching and running the script.