Posts Tagged ‘desktop’

Simplifying Synergy in Gnome
Wednesday, April 9th, 2008

Synergy has worked well for me over the last couple days, but setting up the connection (although not difficult) required a few steps that I’ve tried to streamline.

The following setup is based on a synergy configuration similar to the following.:


section: screens
    desktop:
    laptop:
end
section: links
    desktop:
        right = laptop
    laptop:
        left = desktop
end

BTW, desktop and laptop are arbitrary names I’ve selected for clarity.

Automatically start the synergy server after logging in to gnome on the “desktop” computer to which the mouse/keyboard is physically connected as follows:

  • Go to Main Menu -> System -> Preferences -> Sessions
  • Under Startup Programs click Add
  • In the Edit Startup Program dialog enter the following command to start the synergy server: synergys -n desktop

Since synergy traffic is plaintext, I forward the communication through ssh from my laptop as described in the Synergy documentation. I also use ssh to communicate with my desktop computer for other purposes, so I use public key authentication to avoid having to type my remote password every time I try to connect. Since I use a passphrase, however, I have to add my key to the ssh agent with a call to ssh-add. This requires me to enter my passphrase…but once added I can connect to the desktop machine without a passphrase for the duration of my session. For more info, check out the Ubuntu SSHHowTo documentation. Since I tend to forget to add the key, I decided to run ssh-add when I log into gnome on my laptop (”laptop” above) as follows:

  • Go to Main Menu -> System -> Preferences -> Sessions
  • Under Startup Programs click Add
  • In the Edit Startup Program dialog enter the following to add your key to the authentication agent: ssh-add

In order to establish the synergy client connection, I wrote the following script:


#!/bin/bash
#
# Script to securely connect to synergy
# server on desktop machine for sharing
# keyboard and mouse
#

# IP address of desktop machine
DT_IP="xxx.xxx.xxx.xxx"

# Setup port forwarding
ssh -o ExitOnForwardFailure=true -f -N -L 24800:$DT_IP:24800 $DT_IP

# Start synergy client
killall 'synergyc'
synergyc -1 -n laptop localhost

This script establishes the port forwarding through ssh and then starts the synergy client. Instead of calling the script from the command line, I added a custom application launcher to a panel in order to start the connection with a simple mouse (touchpad) click. There are a few things to note:

  • The ssh connection doesn’t require a passphrase here since I added the key to the authorization agent using ssh-add at gnome startup
  • The ExitOnForwardFailure option is used so that the process will exit if the connection fails. If, for any reason, the synergy client connection is closed, the ssh forwarding will still remain active. This script can be rerun without any worry of multiple (failed) ssh forwarding attempts.
  • The -1 option is used in the synergy client so that it won’t try to restart if the connection fails for any reason. Without this option, the client will continuously attempt to reconnect, consuming system resources.

So now, when I log into gnome on the desktop computer the synergy server automatically starts. When I log into gnome on the laptop machine I am prompted for my ssh passphrase. All I need to do to start a secure synergy connection from my laptop to my desktop is click on my custom application launcher.

Reclaim Desktop Space Using Synergy
Monday, April 7th, 2008

Over the past year and a half I’ve had to relocate my office more times than Milton Waddams, so I’ve become accustomed to traveling light. Each move, however, has required me to adapt to a new desktop arrangement since the office furniture isn’t standard between buildings (or certain locations within them). In the most recent move this past week, I lost about a third of my desktop space and quickly realized I had to modify my cramped arrangement somehow.

Work provides me with a desktop computer, but I prefer to do all of my development work on my laptop which I carry back and forth between work and home. At work, I “dock” the laptop by plugging in a USB keyboard and mouse and connecting an additional monitor for a dual-head setup. So, all together I had two monitors, a laptop, two keyboards and two mice/micepads, a coffee mug, a water cup and a useless phone…but no space for note taking. (Yeah, I still use pen and paper!) Bottom line, I needed to eliminate some clutter on my desktop and the obvious choice was to eliminate a mouse/keyboard pairing.

While typing on the laptop keyboard and navigating around with the touchpad are tolerable for short periods of work, I need an external mouse and keyboard in order to work on my laptop all day. So how do I share a single mouse and keyboard between two computers, each with its own display(s)? Fortunately, a coworker had mentioned Synergy earlier this year and I figured I’d give it a shot. I’m using Ubuntu Gutsy Gibbon on both machines and a quick check of Synaptic showed that Synergy was available for install, so I installed it on the two computers. After a simple configuration, I’m now using the mouse and keyboard connected to my desktop computer seamlessly with the laptop! Excellent utility!

Powered by Laughing Squid