个人工具

“UbuntuHelp:SynergyHowto”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
第1行: 第1行:
 
{{From|https://help.ubuntu.com/community/SynergyHowto}}
 
{{From|https://help.ubuntu.com/community/SynergyHowto}}
 
{{Languages|UbuntuHelp:SynergyHowto}}
 
{{Languages|UbuntuHelp:SynergyHowto}}
 
 
 
Synergy?  What is Synergy?  Synergy is a program that will let you use one keyboard and mouse on multiple computers across a network.  The computers can be running Linux, Windows, or MacOS.  In this howto I will let you know how to get Synergy setup and running on your Ubuntu system.
 
Synergy?  What is Synergy?  Synergy is a program that will let you use one keyboard and mouse on multiple computers across a network.  The computers can be running Linux, Windows, or MacOS.  In this howto I will let you know how to get Synergy setup and running on your Ubuntu system.
 
 
Warning!  Achtung!  Synergy is not very secure at all!  Consider - you are setting up something to allow an entirely different computer control the keyboard and mouse on your own computer!  Don't try and use this anywhere unsecure! There is a way of making it more secure by running it over OpenSSH, but that is currently beyond the scope of this article.  Feel free to read the documentations at the Synergy website.
 
Warning!  Achtung!  Synergy is not very secure at all!  Consider - you are setting up something to allow an entirely different computer control the keyboard and mouse on your own computer!  Don't try and use this anywhere unsecure! There is a way of making it more secure by running it over OpenSSH, but that is currently beyond the scope of this article.  Feel free to read the documentations at the Synergy website.
 
 
=== Obtaining Synergy ===
 
=== Obtaining Synergy ===
 
 
There are a few ways to get Synergy, one of the hardest is to actually get the source code from the Synergy site at http://synergy2.sourceforge.net/index.html, compile it, configure it and run it from the command line.  The easy way is to install an apt package that has already been prepared by Daniel Lutz.  More information about this 'universe' package can be found at http://packages.ubuntu.com/edgy/net/synergy. This guide will explain how to install and use this package.
 
There are a few ways to get Synergy, one of the hardest is to actually get the source code from the Synergy site at http://synergy2.sourceforge.net/index.html, compile it, configure it and run it from the command line.  The easy way is to install an apt package that has already been prepared by Daniel Lutz.  More information about this 'universe' package can be found at http://packages.ubuntu.com/edgy/net/synergy. This guide will explain how to install and use this package.
 
 
If you need to compile the latest version for compatability reasons, see the section below on building from source.
 
If you need to compile the latest version for compatability reasons, see the section below on building from source.
 
 
The first thing that needs done is to actually install the package. There are two ways of doing this, through the command line, or through Synaptic Package Manager.
 
The first thing that needs done is to actually install the package. There are two ways of doing this, through the command line, or through Synaptic Package Manager.
 
 
=== Synaptic Package Manager ===
 
=== Synaptic Package Manager ===
 
Note: you will need to be connected to the internet for this.
 
Note: you will need to be connected to the internet for this.
 
 
1. Add the universe package repository to your repository list.  If you have not done this already, you can find out how to do it at: ''UniversePackages''
 
1. Add the universe package repository to your repository list.  If you have not done this already, you can find out how to do it at: ''UniversePackages''
 
 
2. Click the icon at the top, and select Search.  In the field type "synergy".
 
2. Click the icon at the top, and select Search.  In the field type "synergy".
 
 
3. Click the box next to synergy, and select mark for installation. If your search for synergy comes up blank, check for obvious mistakes first, such as the spelling of synergy, and then make sure that you have correctly added the universe repository to your repository list.
 
3. Click the box next to synergy, and select mark for installation. If your search for synergy comes up blank, check for obvious mistakes first, such as the spelling of synergy, and then make sure that you have correctly added the universe repository to your repository list.
 
 
4. Click the Apply icon at the top and watch it install.
 
4. Click the Apply icon at the top and watch it install.
 
 
=== Installing from the Command Line ===
 
=== Installing from the Command Line ===
 
 
Synergy is kept in the ''universe'' package list,  so you will have to uncomment the universe repositories in ''/etc/apt/sources.list''. If you don't know how to do it go here [[UbuntuHelp:Repositories/Ubuntu]] (for others (Kubuntu, etc) go to the bottom of that page for links).
 
Synergy is kept in the ''universe'' package list,  so you will have to uncomment the universe repositories in ''/etc/apt/sources.list''. If you don't know how to do it go here [[UbuntuHelp:Repositories/Ubuntu]] (for others (Kubuntu, etc) go to the bottom of that page for links).
 
 
Next, this will download lists of any new packages/etc and will install synergy:
 
Next, this will download lists of any new packages/etc and will install synergy:
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo aptitude update && sudo aptitude install synergy
 
sudo aptitude update && sudo aptitude install synergy
 
</nowiki></pre>
 
</nowiki></pre>
 
 
 
=== Building Synergy From Source ===
 
=== Building Synergy From Source ===
 
 
If you've already installed the package for Synergy, this step is not neccecary, you can proceed to the section on Configuring Synergy below.
 
If you've already installed the package for Synergy, this step is not neccecary, you can proceed to the section on Configuring Synergy below.
 
 
Go to http://synergy2.sourceforge.net/ to download the latest source tarball (stable or experimental) and extract it to your home directory.
 
Go to http://synergy2.sourceforge.net/ to download the latest source tarball (stable or experimental) and extract it to your home directory.
 
 
Open a terminal window and change to the directory you just extracted (should be found at ~/synergy-x.x.x where x.x.x is the version number).
 
Open a terminal window and change to the directory you just extracted (should be found at ~/synergy-x.x.x where x.x.x is the version number).
 
 
First we need to make sure we have all the right tools:
 
First we need to make sure we have all the right tools:
 
<pre><nowiki>
 
<pre><nowiki>
第49行: 第28行:
 
sudo apt-get install build-essential
 
sudo apt-get install build-essential
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Now we can setup the build environment and compile then install:
 
Now we can setup the build environment and compile then install:
 
<pre><nowiki>
 
<pre><nowiki>
第55行: 第33行:
 
sudo make install
 
sudo make install
 
</nowiki></pre>
 
</nowiki></pre>
 
 
These will move the executables to the directory referenced in the configuration instructions later:
 
These will move the executables to the directory referenced in the configuration instructions later:
 
<pre><nowiki>
 
<pre><nowiki>
第61行: 第38行:
 
sudo mv /usr/local/bin/synergys /usr/bin
 
sudo mv /usr/local/bin/synergys /usr/bin
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Once the install is finished, you can remove the Synergy folder you extracted earlier and continue to Configuring Synergy.
 
Once the install is finished, you can remove the Synergy folder you extracted earlier and continue to Configuring Synergy.
 
 
=== Configuring Synergy ===
 
=== Configuring Synergy ===
 
 
Now that Synergy is installed, what you need to do is configure it. BUT, you have to configure at least two machines because without two machines using Synergy makes no sense. I will show you the configuration for a server and a client.  I will only show the Ubuntu configuration's, please refer to the [http://synergy2.sourceforge.net/index.html Synergy] site for instructions on configuring other systems.
 
Now that Synergy is installed, what you need to do is configure it. BUT, you have to configure at least two machines because without two machines using Synergy makes no sense. I will show you the configuration for a server and a client.  I will only show the Ubuntu configuration's, please refer to the [http://synergy2.sourceforge.net/index.html Synergy] site for instructions on configuring other systems.
 
 
=== Server Configuration ===
 
=== Server Configuration ===
 
 
synergy.conf can be created in your "Home Folder".
 
synergy.conf can be created in your "Home Folder".
 
 
Here is a copy of my server's configuration.
 
Here is a copy of my server's configuration.
 
<pre><nowiki>
 
<pre><nowiki>
第83行: 第54行:
 
arthur:
 
arthur:
 
left = ubuntu42
 
left = ubuntu42
 
 
end
 
end
 
</nowiki></pre>
 
</nowiki></pre>
 
 
The meaning of the names in the configuration are as follows.   
 
The meaning of the names in the configuration are as follows.   
 
'''Ubuntu42''' is my main machine which acts as a server for Synergy.   
 
'''Ubuntu42''' is my main machine which acts as a server for Synergy.   
第93行: 第62行:
 
'''Screens''' is where you set the host names of the computers going to be used.
 
'''Screens''' is where you set the host names of the computers going to be used.
 
'''Links'''  is what side the mouse will leave the screen of one computer to reach the desktop of the other.  So '''Ubuntu42''' is set to the left of '''Arthur''', so when I drag the mouse off the right hand side of '''Ubuntu42's''' screen it appears on '''Arthur's''' left hand side of the screen.  And vice versa.  You can set the '''Links''' to go out the top of the screen and come in the top of the other screen, you can also set up multiple computers. Multiple here, of course, meaning more than two.
 
'''Links'''  is what side the mouse will leave the screen of one computer to reach the desktop of the other.  So '''Ubuntu42''' is set to the left of '''Arthur''', so when I drag the mouse off the right hand side of '''Ubuntu42's''' screen it appears on '''Arthur's''' left hand side of the screen.  And vice versa.  You can set the '''Links''' to go out the top of the screen and come in the top of the other screen, you can also set up multiple computers. Multiple here, of course, meaning more than two.
 
 
=== Client Configuration ===
 
=== Client Configuration ===
 
 
There is none :) you just install
 
There is none :) you just install
 
 
=== Running Synergy ===
 
=== Running Synergy ===
 
 
From the server you run the command  
 
From the server you run the command  
 
<pre><nowiki>
 
<pre><nowiki>
第112行: 第77行:
 
bash:~$ synergys
 
bash:~$ synergys
 
</nowiki></pre>
 
</nowiki></pre>
 
 
From a client(In this howto the client being Ubuntu), you would issue the command
 
From a client(In this howto the client being Ubuntu), you would issue the command
 
<pre><nowiki>
 
<pre><nowiki>
第118行: 第82行:
 
</nowiki></pre>
 
</nowiki></pre>
 
and that will start the client looking for the server of said address.
 
and that will start the client looking for the server of said address.
 
 
Note: the -f command tells Synergy to run it in the foreground, so that you will be able to output for debugging. If everything works fine, and you are able to move your mouse around, issue the the command  
 
Note: the -f command tells Synergy to run it in the foreground, so that you will be able to output for debugging. If everything works fine, and you are able to move your mouse around, issue the the command  
 
<pre><nowiki>
 
<pre><nowiki>
第124行: 第87行:
 
</nowiki></pre>
 
</nowiki></pre>
 
and you will be up and running.  
 
and you will be up and running.  
 
 
=== Making it Autostart, Gnome ===
 
=== Making it Autostart, Gnome ===
 
 
You probably don't want to have a synergy terminal window open all of the time, so your next step will be to set it up to run as a service.
 
You probably don't want to have a synergy terminal window open all of the time, so your next step will be to set it up to run as a service.
 
 
For those of you who are using a Windows machine as well as Ubuntu, a little gotcha is that when you set Synergy to run at startup, you will also have to start the service in Control Panel -> Administrative Tools -> Services, or by rebooting your computer.
 
For those of you who are using a Windows machine as well as Ubuntu, a little gotcha is that when you set Synergy to run at startup, you will also have to start the service in Control Panel -> Administrative Tools -> Services, or by rebooting your computer.
 
 
Adding Synergy as an autostarting feature of Gnome is a bit more complicated.
 
Adding Synergy as an autostarting feature of Gnome is a bit more complicated.
 
 
But not too painful if you are familar with how Gnome handles login scripts.
 
But not too painful if you are familar with how Gnome handles login scripts.
 
 
The easiest way is probably to pop open a terminal and type the appropriate line without the '-f' option, then you can safely close the terminal and Synergy will continue to run.
 
The easiest way is probably to pop open a terminal and type the appropriate line without the '-f' option, then you can safely close the terminal and Synergy will continue to run.
 
 
If you use some sort of graphical login screen, it is pretty easy to have it autostart. In Ubuntu you can go to your...
 
If you use some sort of graphical login screen, it is pretty easy to have it autostart. In Ubuntu you can go to your...
 
 
System Menu->Preferences->Sessions, click the Startup Programs tab, click "Add" then just enter the Startup Command:
 
System Menu->Preferences->Sessions, click the Startup Programs tab, click "Add" then just enter the Startup Command:
 
 
synergys --config synergy.conf
 
synergys --config synergy.conf
 
 
then click OK & close. This will start the server on a user session basis, not globally.
 
then click OK & close. This will start the server on a user session basis, not globally.
 
 
You can also add a little script in the /etc/X11/Xsession.d folder with a command that says to run it with the bash shell, and then the bash command you use to start synergy.
 
You can also add a little script in the /etc/X11/Xsession.d folder with a command that says to run it with the bash shell, and then the bash command you use to start synergy.
 
 
The name and location of this file is crucial! The file must start with two digits, to specify the order. It really doesn't matter where it is or what the rest of the name is though.  I named mine 12synergy, 22synergy, 32synergy and 54synergy. Sadly, this does not allow you to use synergy on the login screen, but there is a way to do this fortunately for those whom need a way to also use the keyboard prior to final login. You are going to also edit 2 existing files within the X11 directory pertaining to gdm.
 
The name and location of this file is crucial! The file must start with two digits, to specify the order. It really doesn't matter where it is or what the rest of the name is though.  I named mine 12synergy, 22synergy, 32synergy and 54synergy. Sadly, this does not allow you to use synergy on the login screen, but there is a way to do this fortunately for those whom need a way to also use the keyboard prior to final login. You are going to also edit 2 existing files within the X11 directory pertaining to gdm.
 
 
For a client, your new file should look like this, where xxx.xxx.xxx.xxx is the ip address of your server:
 
For a client, your new file should look like this, where xxx.xxx.xxx.xxx is the ip address of your server:
 
<pre><nowiki>
 
<pre><nowiki>
第157行: 第107行:
 
</nowiki></pre>
 
</nowiki></pre>
 
Warning: if you put the -f into the command, you'll get a script that doesn't stop and let gnome finish loading!
 
Warning: if you put the -f into the command, you'll get a script that doesn't stop and let gnome finish loading!
 
 
We want the client to be running when gdm is running, prior to logging in.
 
We want the client to be running when gdm is running, prior to logging in.
 
Add the following to `/etc/X11/gdm/Init/Default`: (just add them to the top of the file)
 
Add the following to `/etc/X11/gdm/Init/Default`: (just add them to the top of the file)
第165行: 第114行:
 
/usr/bin/synergyc xxx.xxx.xxx.xxx
 
/usr/bin/synergyc xxx.xxx.xxx.xxx
 
</nowiki></pre>
 
</nowiki></pre>
 
 
(In 7.10 modification of the PreSession script doesn't seem to be needed)
 
(In 7.10 modification of the PreSession script doesn't seem to be needed)
 
For the client file we must also edit the PreSession script to kill our synergy process running as root before the Xsession scripts run it as user.
 
For the client file we must also edit the PreSession script to kill our synergy process running as root before the Xsession scripts run it as user.
第179行: 第127行:
 
#
 
#
 
PATH="/usr/bin/X11:/usr/X11R6/bin:/opt/X11R6/bin:$PATH:/bin:/usr/bin"
 
PATH="/usr/bin/X11:/usr/X11R6/bin:/opt/X11R6/bin:$PATH:/bin:/usr/bin"
 
 
gdmwhich () {
 
gdmwhich () {
 
COMMAND="$1"
 
COMMAND="$1"
第195行: 第142行:
 
echo "$OUTPUT"
 
echo "$OUTPUT"
 
}
 
}
 
 
# synergyc process, running as root, ends here. This is the last script in the gdm login sequence before things start running as user.
 
# synergyc process, running as root, ends here. This is the last script in the gdm login sequence before things start running as user.
 
/usr/bin/killall synergyc
 
/usr/bin/killall synergyc
 
sleep 1
 
sleep 1
 
 
XSETROOT=`gdmwhich xsetroot`
 
XSETROOT=`gdmwhich xsetroot`
 
if [ "x$XSETROOT" != "x" ] ; then
 
if [ "x$XSETROOT" != "x" ] ; then
第209行: 第154行:
 
"$XSETROOT" -cursor_name left_ptr -solid "$BACKCOLOR"
 
"$XSETROOT" -cursor_name left_ptr -solid "$BACKCOLOR"
 
fi
 
fi
 
 
 
SESSREG=`gdmwhich sessreg`
 
SESSREG=`gdmwhich sessreg`
 
if [ "x$SESSREG" != "x" ] ; then
 
if [ "x$SESSREG" != "x" ] ; then
第219行: 第162行:
 
# this is not reached
 
# this is not reached
 
fi
 
fi
 
 
# some output for easy debugging
 
# some output for easy debugging
 
echo "$0: could not find the sessreg utility, cannot update wtmp and utmp"
 
echo "$0: could not find the sessreg utility, cannot update wtmp and utmp"
第225行: 第167行:
 
</nowiki></pre>
 
</nowiki></pre>
 
Warning: if you put the -f into the command, you'll get a script that doesn't stop and let gnome finish loading!
 
Warning: if you put the -f into the command, you'll get a script that doesn't stop and let gnome finish loading!
 
 
'''For a server, it should look something like this: '''
 
'''For a server, it should look something like this: '''
 
 
Recap: Name this file 12synergy and place it into the /etc/X11/Xsession.d directory!
 
Recap: Name this file 12synergy and place it into the /etc/X11/Xsession.d directory!
 
<pre><nowiki>
 
<pre><nowiki>
第235行: 第175行:
 
synergys --config /full/path/to/synergy.conf
 
synergys --config /full/path/to/synergy.conf
 
</nowiki></pre>
 
</nowiki></pre>
 
 
 
Recap: The server file we must edit, it is contained within `/etc/X11/gdm/PreSession/Default` file!
 
Recap: The server file we must edit, it is contained within `/etc/X11/gdm/PreSession/Default` file!
 
<pre><nowiki>
 
<pre><nowiki>
第248行: 第186行:
 
#
 
#
 
PATH="/usr/bin/X11:/usr/X11R6/bin:/opt/X11R6/bin:$PATH:/bin:/usr/bin"
 
PATH="/usr/bin/X11:/usr/X11R6/bin:/opt/X11R6/bin:$PATH:/bin:/usr/bin"
 
 
gdmwhich () {
 
gdmwhich () {
 
COMMAND="$1"
 
COMMAND="$1"
第268行: 第205行:
 
sleep 1
 
sleep 1
 
synergys --config /full/path/to/synergy.conf
 
synergys --config /full/path/to/synergy.conf
 
 
 
XSETROOT=`gdmwhich xsetroot`
 
XSETROOT=`gdmwhich xsetroot`
 
if [ "x$XSETROOT" != "x" ] ; then
 
if [ "x$XSETROOT" != "x" ] ; then
第279行: 第214行:
 
"$XSETROOT" -cursor_name left_ptr -solid "$BACKCOLOR"
 
"$XSETROOT" -cursor_name left_ptr -solid "$BACKCOLOR"
 
fi
 
fi
 
 
 
SESSREG=`gdmwhich sessreg`
 
SESSREG=`gdmwhich sessreg`
 
if [ "x$SESSREG" != "x" ] ; then
 
if [ "x$SESSREG" != "x" ] ; then
第289行: 第222行:
 
# this is not reached
 
# this is not reached
 
fi
 
fi
 
 
# some output for easy debugging
 
# some output for easy debugging
 
echo "$0: could not find the sessreg utility, cannot update wtmp and utmp"
 
echo "$0: could not find the sessreg utility, cannot update wtmp and utmp"
第295行: 第227行:
 
</nowiki></pre>
 
</nowiki></pre>
 
Warning: if you put the -f into the command, you'll get a script that doesn't stop and let gnome finish loading!
 
Warning: if you put the -f into the command, you'll get a script that doesn't stop and let gnome finish loading!
 
 
=== Making it Autostart, KDE ===
 
=== Making it Autostart, KDE ===
 
 
This makes synergy start soon after your KDE desktop appears, after you have logged in.
 
This makes synergy start soon after your KDE desktop appears, after you have logged in.
 
 
Go to ~/.kde/Autostart
 
Go to ~/.kde/Autostart
 
 
right click > Create New > File > Link to Application
 
right click > Create New > File > Link to Application
 
 
in the general tab, give it a name like runsynergy.
 
in the general tab, give it a name like runsynergy.
 
 
application tab:
 
application tab:
 
type this in the "Command:" field:
 
type this in the "Command:" field:
 
synergyc <replace with the server's IP>
 
synergyc <replace with the server's IP>
 
 
click OK. A file called runsynergy.desktop is created.
 
click OK. A file called runsynergy.desktop is created.
 
if done correctly this works in KDE 3.5.5
 
if done correctly this works in KDE 3.5.5
 
 
'''Creating the .desktop file manually'''
 
'''Creating the .desktop file manually'''
 
 
<pre><nowiki>
 
<pre><nowiki>
 
[Desktop Entry]
 
[Desktop Entry]
第336行: 第259行:
 
X-KDE-Username=
 
X-KDE-Username=
 
X-Ubuntu-Gettext-Domain=desktop_kdebase
 
X-Ubuntu-Gettext-Domain=desktop_kdebase
 
 
</nowiki></pre>
 
</nowiki></pre>
 
 
==== Client Autostart at login screen ====
 
==== Client Autostart at login screen ====
 
 
We want the client to be running when kdm is running, prior to logging in.
 
We want the client to be running when kdm is running, prior to logging in.
 
Add the following to `/etc/kde3/kdm/Xsetup`: (just add them to the end of the file)
 
Add the following to `/etc/kde3/kdm/Xsetup`: (just add them to the end of the file)
第348行: 第268行:
 
/usr/bin/synergyc xxx.xxx.xxx.xxx
 
/usr/bin/synergyc xxx.xxx.xxx.xxx
 
</nowiki></pre>
 
</nowiki></pre>
 
 
For the client file we must also edit the Xstartup script to kill our synergy process running as root before the Xsession scripts run it as user.
 
For the client file we must also edit the Xstartup script to kill our synergy process running as root before the Xsession scripts run it as user.
 
The file is `/etc/kde3/kdm/Xstartup` and it should look like this:
 
The file is `/etc/kde3/kdm/Xstartup` and it should look like this:
第354行: 第273行:
 
#! /bin/sh
 
#! /bin/sh
 
# Xstartup - run as root before session starts
 
# Xstartup - run as root before session starts
 
 
PATH="$PATH:/usr/bin/X11"
 
PATH="$PATH:/usr/bin/X11"
 
 
if [ -e /etc/nologin ]; then
 
if [ -e /etc/nologin ]; then
 
# always display the nologin message, if possible
 
# always display the nologin message, if possible
第367行: 第284行:
 
fi
 
fi
 
fi
 
fi
 
 
# synergyc process, running as root, ends here. This is the last script in the gdm login sequence before things start running as user.
 
# synergyc process, running as root, ends here. This is the last script in the gdm login sequence before things start running as user.
 
/usr/bin/killall synergyc
 
/usr/bin/killall synergyc
 
sleep 1
 
sleep 1
 
 
if grep -qs '^use-sessreg' /etc/kde3/kdm/kdm.options && \
 
if grep -qs '^use-sessreg' /etc/kde3/kdm/kdm.options && \
 
which sessreg > /dev/null 2>&1; then
 
which sessreg > /dev/null 2>&1; then
第380行: 第295行:
 
</nowiki></pre>
 
</nowiki></pre>
 
Warning: if you put the -f into the command, you'll get a script that doesn't stop and let kde finish loading!
 
Warning: if you put the -f into the command, you'll get a script that doesn't stop and let kde finish loading!
 
 
==== Server Autostart at login screen ====
 
==== Server Autostart at login screen ====
 
TODO.
 
TODO.
 
 
=== Wrapup ===
 
=== Wrapup ===
 
 
Now that you have synergy installed and running, you can copy and paste between machines and also just have all out fun with the keyboard and mouse on both/or more machines.  I use Synergy all the time, that way I can write in one window and talk/chat/read mail in another window.  It makes using multiple computers a lot easier and a lot more fun.
 
Now that you have synergy installed and running, you can copy and paste between machines and also just have all out fun with the keyboard and mouse on both/or more machines.  I use Synergy all the time, that way I can write in one window and talk/chat/read mail in another window.  It makes using multiple computers a lot easier and a lot more fun.
 
 
[[category:CategoryDocumentation]]
 
[[category:CategoryDocumentation]]
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2007年11月30日 (五) 21:40的版本

Synergy? What is Synergy? Synergy is a program that will let you use one keyboard and mouse on multiple computers across a network. The computers can be running Linux, Windows, or MacOS. In this howto I will let you know how to get Synergy setup and running on your Ubuntu system. Warning! Achtung! Synergy is not very secure at all! Consider - you are setting up something to allow an entirely different computer control the keyboard and mouse on your own computer! Don't try and use this anywhere unsecure! There is a way of making it more secure by running it over OpenSSH, but that is currently beyond the scope of this article. Feel free to read the documentations at the Synergy website.

Obtaining Synergy

There are a few ways to get Synergy, one of the hardest is to actually get the source code from the Synergy site at http://synergy2.sourceforge.net/index.html, compile it, configure it and run it from the command line. The easy way is to install an apt package that has already been prepared by Daniel Lutz. More information about this 'universe' package can be found at http://packages.ubuntu.com/edgy/net/synergy. This guide will explain how to install and use this package. If you need to compile the latest version for compatability reasons, see the section below on building from source. The first thing that needs done is to actually install the package. There are two ways of doing this, through the command line, or through Synaptic Package Manager.

Synaptic Package Manager

Note: you will need to be connected to the internet for this. 1. Add the universe package repository to your repository list. If you have not done this already, you can find out how to do it at: UniversePackages 2. Click the icon at the top, and select Search. In the field type "synergy". 3. Click the box next to synergy, and select mark for installation. If your search for synergy comes up blank, check for obvious mistakes first, such as the spelling of synergy, and then make sure that you have correctly added the universe repository to your repository list. 4. Click the Apply icon at the top and watch it install.

Installing from the Command Line

Synergy is kept in the universe package list, so you will have to uncomment the universe repositories in /etc/apt/sources.list. If you don't know how to do it go here UbuntuHelp:Repositories/Ubuntu (for others (Kubuntu, etc) go to the bottom of that page for links). Next, this will download lists of any new packages/etc and will install synergy:

sudo aptitude update && sudo aptitude install synergy

Building Synergy From Source

If you've already installed the package for Synergy, this step is not neccecary, you can proceed to the section on Configuring Synergy below. Go to http://synergy2.sourceforge.net/ to download the latest source tarball (stable or experimental) and extract it to your home directory. Open a terminal window and change to the directory you just extracted (should be found at ~/synergy-x.x.x where x.x.x is the version number). First we need to make sure we have all the right tools:

sudo apt-get install libxtst-dev
sudo apt-get install build-essential

Now we can setup the build environment and compile then install:

sudo ./configure -x-libraries /usr/lib -x-includes /usr/includes
sudo make install

These will move the executables to the directory referenced in the configuration instructions later:

sudo mv /usr/local/bin/synergyc /usr/bin
sudo mv /usr/local/bin/synergys /usr/bin

Once the install is finished, you can remove the Synergy folder you extracted earlier and continue to Configuring Synergy.

Configuring Synergy

Now that Synergy is installed, what you need to do is configure it. BUT, you have to configure at least two machines because without two machines using Synergy makes no sense. I will show you the configuration for a server and a client. I will only show the Ubuntu configuration's, please refer to the Synergy site for instructions on configuring other systems.

Server Configuration

synergy.conf can be created in your "Home Folder". Here is a copy of my server's configuration.

section: screens
ubuntu42:
arthur:
end
section: links
ubuntu42:
right = arthur
arthur:
left = ubuntu42
end

The meaning of the names in the configuration are as follows. Ubuntu42 is my main machine which acts as a server for Synergy. Arthur is the client(another Ubuntu machine(laptop)) that I use my desktop's keyboard and mouse with. Section is where you lay out different configurations Screens is where you set the host names of the computers going to be used. Links is what side the mouse will leave the screen of one computer to reach the desktop of the other. So Ubuntu42 is set to the left of Arthur, so when I drag the mouse off the right hand side of Ubuntu42's screen it appears on Arthur's left hand side of the screen. And vice versa. You can set the Links to go out the top of the screen and come in the top of the other screen, you can also set up multiple computers. Multiple here, of course, meaning more than two.

Client Configuration

There is none :) you just install

Running Synergy

From the server you run the command

bash:~$ synergys -f --config synergy.conf

and that will start running the server in the foreground. If the synergy server works without any issue, do the following.

bash:~$ mv synergy.conf ~/.synergy.conf

If you do the above, you will be able to start synergy server simply by doing

bash:~$ synergys

From a client(In this howto the client being Ubuntu), you would issue the command

bash:~$ synergyc -f <ip address of server>

and that will start the client looking for the server of said address. Note: the -f command tells Synergy to run it in the foreground, so that you will be able to output for debugging. If everything works fine, and you are able to move your mouse around, issue the the command

synergyc <ip.address.of.server>

and you will be up and running.

Making it Autostart, Gnome

You probably don't want to have a synergy terminal window open all of the time, so your next step will be to set it up to run as a service. For those of you who are using a Windows machine as well as Ubuntu, a little gotcha is that when you set Synergy to run at startup, you will also have to start the service in Control Panel -> Administrative Tools -> Services, or by rebooting your computer. Adding Synergy as an autostarting feature of Gnome is a bit more complicated. But not too painful if you are familar with how Gnome handles login scripts. The easiest way is probably to pop open a terminal and type the appropriate line without the '-f' option, then you can safely close the terminal and Synergy will continue to run. If you use some sort of graphical login screen, it is pretty easy to have it autostart. In Ubuntu you can go to your... System Menu->Preferences->Sessions, click the Startup Programs tab, click "Add" then just enter the Startup Command: synergys --config synergy.conf then click OK & close. This will start the server on a user session basis, not globally. You can also add a little script in the /etc/X11/Xsession.d folder with a command that says to run it with the bash shell, and then the bash command you use to start synergy. The name and location of this file is crucial! The file must start with two digits, to specify the order. It really doesn't matter where it is or what the rest of the name is though. I named mine 12synergy, 22synergy, 32synergy and 54synergy. Sadly, this does not allow you to use synergy on the login screen, but there is a way to do this fortunately for those whom need a way to also use the keyboard prior to final login. You are going to also edit 2 existing files within the X11 directory pertaining to gdm. For a client, your new file should look like this, where xxx.xxx.xxx.xxx is the ip address of your server:

#/bin/bash
/usr/bin/killall synergyc
sleep 1
/usr/bin/synergyc xxx.xxx.xxx.xxx

Warning: if you put the -f into the command, you'll get a script that doesn't stop and let gnome finish loading! We want the client to be running when gdm is running, prior to logging in. Add the following to `/etc/X11/gdm/Init/Default`: (just add them to the top of the file)

/usr/bin/killall synergyc
sleep 1
/usr/bin/synergyc xxx.xxx.xxx.xxx

(In 7.10 modification of the PreSession script doesn't seem to be needed) For the client file we must also edit the PreSession script to kill our synergy process running as root before the Xsession scripts run it as user. The file is `/etc/X11/gdm/PreSession/Default` and it should look like this:

#!/bin/sh
#
# Note that any setup should come before the sessreg command as
# that must be 'exec'ed for the pid to be correct (sessreg uses the parent
# pid)
#
# Note that output goes into the .xsession-errors file for easy debugging
#
PATH="/usr/bin/X11:/usr/X11R6/bin:/opt/X11R6/bin:$PATH:/bin:/usr/bin"
gdmwhich () {
COMMAND="$1"
OUTPUT=
IFS=:
for dir in $PATH
do
if test -x "$dir/$COMMAND" ; then
if test "x$OUTPUT" = "x" ; then
OUTPUT="$dir/$COMMAND"
fi
fi
done
unset IFS
echo "$OUTPUT"
}
# synergyc process, running as root, ends here. This is the last script in the gdm login sequence before things start running as user.
/usr/bin/killall synergyc
sleep 1
XSETROOT=`gdmwhich xsetroot`
if [ "x$XSETROOT" != "x" ] ; then
# Try to snarf the BackgroundColor from the config file
BACKCOLOR=`grep '<sup>BackgroundColor' /etc/gdm/gdm.conf | sed 's/</sup>.*=\(.*\)$/\1/'`
if [ "x$BACKCOLOR" = "x" ]; then
BACKCOLOR="#76848F"
fi
"$XSETROOT" -cursor_name left_ptr -solid "$BACKCOLOR"
fi
SESSREG=`gdmwhich sessreg`
if [ "x$SESSREG" != "x" ] ; then
# some output for easy debugging
echo "$0: Registering your session with wtmp and utmp"
echo "$0: running: $SESSREG -a -w /var/log/wtmp -u /var/run/utmp -x \"$X_SERVERS\" -h \"$REMOTE_HOST\" -l \"$DISPLAY$
exec "$SESSREG" -a -w /var/log/wtmp -u /var/run/utmp -x "$X_SERVERS" -h "$REMOTE_HOST" -l "$DISPLAY" "$USER"
# this is not reached
fi
# some output for easy debugging
echo "$0: could not find the sessreg utility, cannot update wtmp and utmp"
exit 0

Warning: if you put the -f into the command, you'll get a script that doesn't stop and let gnome finish loading! For a server, it should look something like this: Recap: Name this file 12synergy and place it into the /etc/X11/Xsession.d directory!

#/bin/bash
/usr/bin/killall synergys
sleep 1
synergys --config /full/path/to/synergy.conf

Recap: The server file we must edit, it is contained within `/etc/X11/gdm/PreSession/Default` file!

#!/bin/sh
#
# Note that any setup should come before the sessreg command as
# that must be 'exec'ed for the pid to be correct (sessreg uses the parent
# pid)
#
# Note that output goes into the .xsession-errors file for easy debugging
#
PATH="/usr/bin/X11:/usr/X11R6/bin:/opt/X11R6/bin:$PATH:/bin:/usr/bin"
gdmwhich () {
COMMAND="$1"
OUTPUT=
IFS=:
for dir in $PATH
do
if test -x "$dir/$COMMAND" ; then
if test "x$OUTPUT" = "x" ; then
OUTPUT="$dir/$COMMAND"
fi
fi
done
unset IFS
echo "$OUTPUT"
}
#Synergy Server Starts at login and dies at logoff!
/usr/bin/killall synergys
sleep 1
synergys --config /full/path/to/synergy.conf
XSETROOT=`gdmwhich xsetroot`
if [ "x$XSETROOT" != "x" ] ; then
# Try to snarf the BackgroundColor from the config file
BACKCOLOR=`grep '<sup>BackgroundColor' /etc/gdm/gdm.conf | sed 's/</sup>.*=\(.*\)$/\1/'`
if [ "x$BACKCOLOR" = "x" ]; then
BACKCOLOR="#76848F"
fi
"$XSETROOT" -cursor_name left_ptr -solid "$BACKCOLOR"
fi
SESSREG=`gdmwhich sessreg`
if [ "x$SESSREG" != "x" ] ; then
# some output for easy debugging
echo "$0: Registering your session with wtmp and utmp"
echo "$0: running: $SESSREG -a -w /var/log/wtmp -u /var/run/utmp -x \"$X_SERVERS\" -h \"$REMOTE_HOST\" -l \"$DISPLAY$
exec "$SESSREG" -a -w /var/log/wtmp -u /var/run/utmp -x "$X_SERVERS" -h "$REMOTE_HOST" -l "$DISPLAY" "$USER"
# this is not reached
fi
# some output for easy debugging
echo "$0: could not find the sessreg utility, cannot update wtmp and utmp"
exit 0

Warning: if you put the -f into the command, you'll get a script that doesn't stop and let gnome finish loading!

Making it Autostart, KDE

This makes synergy start soon after your KDE desktop appears, after you have logged in. Go to ~/.kde/Autostart right click > Create New > File > Link to Application in the general tab, give it a name like runsynergy. application tab: type this in the "Command:" field: synergyc <replace with the server's IP> click OK. A file called runsynergy.desktop is created. if done correctly this works in KDE 3.5.5 Creating the .desktop file manually

[Desktop Entry]
Comment=
Comment[en_US]=
Encoding=UTF-8
Exec=synergyc <replace with the server's IP>
GenericName=
GenericName[en_US]=
Icon=
MimeType=
Name=
Name[en_US]=
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-DCOP-ServiceType=
X-KDE-SubstituteUID=false
X-KDE-Username=
X-Ubuntu-Gettext-Domain=desktop_kdebase

Client Autostart at login screen

We want the client to be running when kdm is running, prior to logging in. Add the following to `/etc/kde3/kdm/Xsetup`: (just add them to the end of the file)

/usr/bin/killall synergyc
sleep 1
/usr/bin/synergyc xxx.xxx.xxx.xxx

For the client file we must also edit the Xstartup script to kill our synergy process running as root before the Xsession scripts run it as user. The file is `/etc/kde3/kdm/Xstartup` and it should look like this:

#! /bin/sh
# Xstartup - run as root before session starts
PATH="$PATH:/usr/bin/X11"
if [ -e /etc/nologin ]; then
# always display the nologin message, if possible
if [ -s /etc/nologin ] && which xmessage > /dev/null 2>&1; then
xmessage -file /etc/nologin -geometry 640x480
fi
if [ "$(id -u)" != "0" ] && \
! grep -qs '^ignore-nologin' /etc/kde3/kdm/kdm.options; then
exit 1
fi
fi
# synergyc process, running as root, ends here. This is the last script in the gdm login sequence before things start running as user.
/usr/bin/killall synergyc
sleep 1
if grep -qs '^use-sessreg' /etc/kde3/kdm/kdm.options && \
which sessreg > /dev/null 2>&1; then
exec sessreg -a -l "$DISPLAY" -u /var/run/utmp \
-h "`echo $DISPLAY | cut -d: -f1`" "$USER"
# NOTREACHED
fi

Warning: if you put the -f into the command, you'll get a script that doesn't stop and let kde finish loading!

Server Autostart at login screen

TODO.

Wrapup

Now that you have synergy installed and running, you can copy and paste between machines and also just have all out fun with the keyboard and mouse on both/or more machines. I use Synergy all the time, that way I can write in one window and talk/chat/read mail in another window. It makes using multiple computers a lot easier and a lot more fun.