Sunday 27 July 2008

Sharing a mouse and keyboard with Synergy

If, like me, you have two computers on your desk with two keyboards and two mice and find yourself occasionally typing something on the wrong computer or clicking with the wrong mouse then this tip is for you.

First you need to install synergy on both computers;

sudo apt-get install synergy

Then choose one of the two to be the "server". You will use the keyboard and mouse that is connected to this computer. In this example the two PC's are side by side.

You will only need a configuration file on the server PC. Create one;

sudo vi /etc/synergy.conf

# sample synergy configuration file
#
# comments begin with the # character and continue to the end of
# line. comments may appear anywhere the syntax permits.

section: screens
server_pc:
client_pc:
end
section: links
server_pc:
left = client_pc
client_pc:
right = server_pc
end

Where server_pc and client_pc are the names of the two computers.

For example, my server PC is called "jupiter" and the client is called "saturn". The server is on the right (client on the left)


# sample synergy configuration file
#
# comments begin with the # character and continue to the end of
# line. comments may appear anywhere the syntax permits.

section: screens

earth:
saturn:

end

section: links
earth:
left = saturn

saturn:
right = earth
end


You can test the the setup with these commands;

On the server:

synergys -f --config /etc/synergy.conf

On the client:

synergyc -f server_pc

To start synergy automatically when gnome starts;

sudo gedit /etc/gdm/Init/Default

Add these lines just before the "sysmodmap=/etc/X11/Xmodmap" line:

On the server:

SYNERGYS=`gdmwhich synergys`
if [ x$SYNERGYS != x ] ; then $SYNERGYS --config /etc/synergy.conf
fi

On the client;

SYNERGYC=`gdmwhich synergyc`
if [ x$SYNERGYC != x ] ; then $SYNERGYC server_pc
fi

This starts synergy at the gnome login screen. Once you log in gnome kills the server so you need to start it again for your user session;

sudo gedit /etc/gdm/PreSession/Default

Add the same lines this time just before the "XSETROOT=`gdmwhich xsetroot`" line;

On the server:

SYNERGYS=`gdmwhich synergys`
if [ x$SYNERGYS != x ] ; then $SYNERGYS --config /etc/synergy.conf
fi

On the client;

SYNERGYC=`gdmwhich synergyc`
if [ x$SYNERGYC != x ] ; then $SYNERGYC server_pc
fi

Once you restart gnome on both the PC's you should be able to move the mouse left and right between the two screens. Keyboard focus will follow the mouse pointer.

No comments: