个人工具

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

来自Ubuntu中文

跳转至: 导航, 搜索
(新页面: {{From|https://help.ubuntu.com/community/SynergyHowto}} {{Languages|UbuntuHelp:SynergyHowto}} Synergy? What is Synergy? Synergy is a program that will let you use one keyboard and mou...)
 
 
(未显示2个用户的11个中间版本)
第1行: 第1行:
 
{{From|https://help.ubuntu.com/community/SynergyHowto}}
 
{{From|https://help.ubuntu.com/community/SynergyHowto}}
 
{{Languages|UbuntuHelp:SynergyHowto}}
 
{{Languages|UbuntuHelp:SynergyHowto}}
 +
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.  The computer with the keyboard and mouse is the '''server''' or '''host''', and the computers with the displays to be controlled remotely are the '''clients'''.  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.  More documentation is available on the [http://synergy2.sourceforge.net/ Synergy website].
 +
=== Quickstart Guide ===
 +
There is a graphical tool available in the universe repositories for easily configuring and starting Synergy on both server and client computer called QuickSynergy. If you don't already know either the hostname of these computers, run the <code><nowiki>hostname</nowiki></code> command from a [[UbuntuHelp:UsingTheTerminal|Terminal window]].
 +
==== On the Client(s) ====
 +
Follow these steps on the computer you would like to control with a remote keyboard and mouse.
 +
<ol><li>[[UbuntuHelp:apt:quicksynergy|Install QuickSynergy]] and open it (under Applications > Accessories)
 +
</li><li>Under the 'Use' tab, type the hostname or IP address of the Host machine in the IP field, and the hostname of the Client machine in the Screen field.
 +
</li><li>Click Execute</li></ol>
  
 +
==== On the Server ====
 +
Follow these steps on the computer with the keyboard and mouse.
 +
<ol><li>[[UbuntuHelp:apt:quicksynergy|Install QuickSynergy]] and open it (under Applications > Accessories)
 +
</li><li>Under the 'Share' tab enter the hostname or IP address of the Client machines in one of the directional boxes. The directional box you choose will determine which edge of the Host computer's screen the mouse will "run off".
 +
</li><li>Click Execute
 +
</li><li>Move the mouse to the edge of the Host screen -- it should now appear on the client screen.</li></ol>
  
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.
+
=== Manual Configuration ===
 
+
The following steps assume you are setting up synergy on a host computer named '''myserver''' and a client computer named '''myclient'''.
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.
+
==== On the Server ====
 
+
Synergy configuration can go in your home folder called '''.synergy.conf''' or in '''/etc/synergy.conf'''. It is up to you whether you would like the changes to be per-user or system-wide.
=== Obtaining Synergy ===
+
Here is a sample configuration that will be the needs of 95% of users:
 
+
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:
+
 
<pre><nowiki>
 
<pre><nowiki>
sudo aptitude update && sudo aptitude install synergy
+
section: screens
</nowiki></pre>
+
        myserver:
 +
        myclient:
 +
end
 +
section: links
 +
        myserver:
 +
                right = myclient
 +
        myclient:
 +
                left = myserver
  
 
+
end
=== 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:
+
<pre><nowiki>
+
sudo apt-get install libxtst-dev
+
sudo apt-get install build-essential
+
 
</nowiki></pre>
 
</nowiki></pre>
 
+
'''myserver''' is the hostname of the computer running synergys (providing the keyboard and mouse)
Now we can setup the build environment and compile then install:
+
'''myclient''' is the hostneme of the computer running synergyc (using the keyboard and mouse provided by myserver)
 +
'''section: screens''' is where you set the host names of the computers going to be used.
 +
'''section: links'''  is what side the mouse will leave the screen of one computer to reach the desktop of the other.  '''myserver''' is set to the left of '''myclient''', so when I drag the mouse off the right hand side of '''myserver''''s screen it appears on the left hand side '''myclient''''s screen.  Use '''up'''/'''down''' instead of '''left'''/'''right''' to establish and over/under sort of relationship.
 +
==== Running Synergy ====
 +
From the server, run the command:
 
<pre><nowiki>
 
<pre><nowiki>
sudo ./configure -x-libraries /usr/lib -x-includes /usr/includes
+
synergys
sudo make install
+
 
</nowiki></pre>
 
</nowiki></pre>
 
+
From the client, run the command:
These will move the executables to the directory referenced in the configuration instructions later:
+
 
<pre><nowiki>
 
<pre><nowiki>
sudo mv /usr/local/bin/synergyc /usr/bin
+
synergyc <SERVER HOSTNAME>
sudo mv /usr/local/bin/synergys /usr/bin
+
 
</nowiki></pre>
 
</nowiki></pre>
 
+
Replacing <SERVER HOSTNAME> with either the hostname ('''myclient''') or IP address of '''myclient'''.
Once the install is finished, you can remove the Synergy folder you extracted earlier and continue to Configuring Synergy.
+
You should now be able to move your mouse pointer off the right edge of your server's screen and see it show up at the left side of your client's screen. See the steps in the next section to make synergy start automatically on the host and client computers.
 
+
If you have any problems at this point it is helpful to run synergys and synergyc in the foreground with the '''-f''' option. This allows you to see error/status information that synergy prints to the terminal.
=== Configuring Synergy ===
+
=== Autostart Synergy after logging in (GNOME) ===
 
+
==== On the Server ====
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.
+
Follow these steps to start synergys when you log into GNOME.
 
+
Go to System Menu > Preferences > Startup Applications. Click "Add" and enter
=== Server Configuration ===
+
<code><nowiki>synergys</nowiki></code>
 
+
Click OK and Close.
synergy.conf can be created in your "Home Folder".
+
=== Autostart Synergy before logging in (GDM) ===
 
+
Note:  Autostarting Synergy before logging in requires that your network connection be available at all times and not just after you log in.  This is accomplished by enabling the network connection for all users.  To do this, choose System->Preference->Network Connections.  Choose the network name and select Edit.  Select "Available to all users", and then click "Apply".  This connection will now be available at all times, including at the GDM login screen.  
Here is a copy of my server's configuration.
+
To make sure synergy is running at all times, the following has to happen:  First, synergy is started when the GDM login screen starts. Then, synergy is killed and restarted when a user logs in. When the user logs out, synergy is killed and GDM starts it again. To edit system configuration files in the following sections open a text editor as the root user:
 
<pre><nowiki>
 
<pre><nowiki>
section: screens
+
sudo gedit
ubuntu42:
+
arthur:
+
end
+
section: links
+
ubuntu42:
+
right = arthur
+
arthur:
+
left = ubuntu42
+
 
+
end
+
 
</nowiki></pre>
 
</nowiki></pre>
 
+
==== On the Server ====
The meaning of the names in the configuration are as follows. 
+
At the end of the file <code><nowiki>/etc/gdm/Init/Default</nowiki></code>, just before the line that says <code><nowiki>exit 0</nowiki></code> add the following:
'''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
+
 
<pre><nowiki>
 
<pre><nowiki>
bash:~$ synergys -f --config synergy.conf
+
/usr/bin/killall synergys
 +
while [ $(pgrep -x synergys) ]; do sleep 0.1; done
 +
/usr/bin/synergys
 
</nowiki></pre>
 
</nowiki></pre>
and that will start running the server in the foreground. If the synergy server works without any issue, do the following.
+
Add the following to the end of <code><nowiki>/etc/gdm/PostLogin/Default</nowiki></code> (create this file file if it does not already exist):
 
<pre><nowiki>
 
<pre><nowiki>
bash:~$ mv synergy.conf ~/.synergy.conf
+
/usr/bin/killall synergys
 +
while [ $(pgrep -x synergys) ]; do sleep 0.1; done
 
</nowiki></pre>
 
</nowiki></pre>
If you do the above, you will be able to start synergy server simply by doing
+
If you created the file, make sure it is executable with this command:
 
<pre><nowiki>
 
<pre><nowiki>
bash:~$ synergys
+
sudo chmod +x /etc/gdm/PostLogin/Default
 
</nowiki></pre>
 
</nowiki></pre>
 
+
Now, create a session file <code><nowiki>/etc/X11/Xsession.d/85synergys</nowiki></code> with the following contents
From a client(In this howto the client being Ubuntu), you would issue the command
+
 
<pre><nowiki>
 
<pre><nowiki>
bash:~$ synergyc -f <ip address of server>
+
/usr/bin/killall synergys
 +
while [ $(pgrep -x synergys) ]; do sleep 0.1; done
 +
/usr/bin/synergys
 
</nowiki></pre>
 
</nowiki></pre>
and that will start the client looking for the server of said address.
+
Lastly, we must make the file executable with this 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>
synergyc <ip.address.of.server>
+
sudo chmod +x /etc/X11/Xsession.d/85synergys
 
</nowiki></pre>
 
</nowiki></pre>
and you will be up and running.
+
==== On the Client ====
 
+
At the end of <code><nowiki>/etc/gdm/Init/Default</nowiki></code>, just before the line that says <code><nowiki>exit 0</nowiki></code> add the following:
=== 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:
+
 
<pre><nowiki>
 
<pre><nowiki>
#/bin/bash
 
 
/usr/bin/killall synergyc
 
/usr/bin/killall synergyc
sleep 1
+
while [ $(pgrep -x synergyc) ]; do sleep 0.1; done
/usr/bin/synergyc xxx.xxx.xxx.xxx
+
/usr/bin/synergyc <SERVER HOSTNAME>
 
</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!
+
Be sure to replace <SERVER HOSTNAME> with the host name or IP address of the computer running synergys.
 
+
Add the following to the end of <code><nowiki>/etc/gdm/PostLogin/Default</nowiki></code> (create this file file if it does not already exist):
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)
+
 
<pre><nowiki>
 
<pre><nowiki>
 
/usr/bin/killall synergyc
 
/usr/bin/killall synergyc
sleep 1
+
while [ $(pgrep -x synergyc) ]; do sleep 0.1; done
/usr/bin/synergyc xxx.xxx.xxx.xxx
+
 
</nowiki></pre>
 
</nowiki></pre>
 
+
If you created the file, make sure it is executable with this command:
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:
+
 
<pre><nowiki>
 
<pre><nowiki>
#!/bin/sh
+
sudo chmod +x /etc/gdm/PostLogin/Default
#
+
# 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
+
 
</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!
+
Now, create a session file <code><nowiki>/etc/X11/Xsession.d/85synergyc</nowiki></code> with the following contents
 
+
'''For a server, it should look something like this: '''
+
 
+
Recap: Name this file 12synergy and place it into the /etc/X11/Xsession.d directory!
+
 
<pre><nowiki>
 
<pre><nowiki>
#/bin/bash
+
/usr/bin/killall synergyc
/usr/bin/killall synergys
+
while [ $(pgrep -x synergyc) ]; do sleep 0.1; done
sleep 1
+
/usr/bin/synergyc <SERVER HOSTNAME>
synergys --config /full/path/to/synergy.conf
+
 
</nowiki></pre>
 
</nowiki></pre>
 
+
This will run synergyc when any user logs in. Be sure to replace <SERVER HOSTNAME> with the host name or IP address of the computer running synergys.  Lastly, we must make the file executable with this command:
 
+
Recap: The server file we must edit, it is contained within `/etc/X11/gdm/PreSession/Default` file!
+
 
<pre><nowiki>
 
<pre><nowiki>
#!/bin/sh
+
sudo chmod +x /etc/X11/Xsession.d/85synergyc
#
+
# 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
+
 
</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!
+
=== Autostart Synergy before logging in (KDM) ===
 
+
==== On the Client ====
=== Making it Autostart, KDE ===
+
Follow these steps to start the synergyc client when the KDM login screen launches.
 
+
Add the following to the end of `/etc/kde3/kdm/Xsetup`:
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'''
+
 
+
<pre><nowiki>
+
[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
+
 
+
</nowiki></pre>
+
 
+
==== 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)
+
 
<pre><nowiki>
 
<pre><nowiki>
 
/usr/bin/killall synergyc
 
/usr/bin/killall synergyc
 
sleep 1
 
sleep 1
/usr/bin/synergyc xxx.xxx.xxx.xxx
+
/usr/bin/synergyc <SERVER HOSTNAME>
 
</nowiki></pre>
 
</nowiki></pre>
 
+
Be sure to replace <SERVER HOSTNAME> with the host name or IP address of the computer running synergys.
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 synergyc process running as root before the user Xsession scripts run. To do this add the following to the end of `/etc/kde3/kdm/Xstartup` and it should look like this:
The file is `/etc/kde3/kdm/Xstartup` and it should look like this:
+
 
<pre><nowiki>
 
<pre><nowiki>
 
#! /bin/sh
 
#! /bin/sh
第357行: 第135行:
  
 
if [ -e /etc/nologin ]; then
 
if [ -e /etc/nologin ]; then
# always display the nologin message, if possible
+
  # always display the nologin message, if possible
if [ -s /etc/nologin ] && which xmessage > /dev/null 2>&1; then
+
  if [ -s /etc/nologin ] && which xmessage > /dev/null 2>&1; then
xmessage -file /etc/nologin -geometry 640x480
+
    xmessage -file /etc/nologin -geometry 640x480
fi
+
  fi
if [ "$(id -u)" != "0" ] && \
+
  if [ "$(id -u)" != "0" ] && \
! grep -qs '^ignore-nologin' /etc/kde3/kdm/kdm.options; then
+
    ! grep -qs '^ignore-nologin' /etc/kde3/kdm/kdm.options; then
exit 1
+
    exit 1
fi
+
  fi
 
fi
 
fi
  
第372行: 第150行:
  
 
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
exec sessreg -a -l "$DISPLAY" -u /var/run/utmp \
+
      exec sessreg -a -l "$DISPLAY" -u /var/run/utmp \
-h "`echo $DISPLAY | cut -d: -f1`" "$USER"
+
                  -h "`echo $DISPLAY | cut -d: -f1`" "$USER"
# NOTREACHED
+
      # NOTREACHED
 
fi
 
fi
 
</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!
+
=== See Also ===
 
+
[http://synergy2.sourceforge.net/ Synergy Homepage]
==== Server Autostart at login screen ====
+
[http://code.google.com/p/quicksynergy/ QuickSynergy Homepage]
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.
+
 
+
[[category:CategoryDocumentation]]
+
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2010年5月20日 (四) 00:21的最新版本

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. The computer with the keyboard and mouse is the server or host, and the computers with the displays to be controlled remotely are the clients. 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. More documentation is available on the Synergy website.

Quickstart Guide

There is a graphical tool available in the universe repositories for easily configuring and starting Synergy on both server and client computer called QuickSynergy. If you don't already know either the hostname of these computers, run the hostname command from a Terminal window.

On the Client(s)

Follow these steps on the computer you would like to control with a remote keyboard and mouse.

  1. Install QuickSynergy and open it (under Applications > Accessories)
  2. Under the 'Use' tab, type the hostname or IP address of the Host machine in the IP field, and the hostname of the Client machine in the Screen field.
  3. Click Execute

On the Server

Follow these steps on the computer with the keyboard and mouse.

  1. Install QuickSynergy and open it (under Applications > Accessories)
  2. Under the 'Share' tab enter the hostname or IP address of the Client machines in one of the directional boxes. The directional box you choose will determine which edge of the Host computer's screen the mouse will "run off".
  3. Click Execute
  4. Move the mouse to the edge of the Host screen -- it should now appear on the client screen.

Manual Configuration

The following steps assume you are setting up synergy on a host computer named myserver and a client computer named myclient.

On the Server

Synergy configuration can go in your home folder called .synergy.conf or in /etc/synergy.conf. It is up to you whether you would like the changes to be per-user or system-wide. Here is a sample configuration that will be the needs of 95% of users:

section: screens
        myserver:
        myclient:
end
section: links
        myserver:
                right = myclient
        myclient:
                left = myserver

end

myserver is the hostname of the computer running synergys (providing the keyboard and mouse) myclient is the hostneme of the computer running synergyc (using the keyboard and mouse provided by myserver) section: screens is where you set the host names of the computers going to be used. section: links is what side the mouse will leave the screen of one computer to reach the desktop of the other. myserver is set to the left of myclient, so when I drag the mouse off the right hand side of myserver's screen it appears on the left hand side myclient's screen. Use up/down instead of left/right to establish and over/under sort of relationship.

Running Synergy

From the server, run the command:

synergys

From the client, run the command:

synergyc <SERVER HOSTNAME>

Replacing <SERVER HOSTNAME> with either the hostname (myclient) or IP address of myclient. You should now be able to move your mouse pointer off the right edge of your server's screen and see it show up at the left side of your client's screen. See the steps in the next section to make synergy start automatically on the host and client computers. If you have any problems at this point it is helpful to run synergys and synergyc in the foreground with the -f option. This allows you to see error/status information that synergy prints to the terminal.

Autostart Synergy after logging in (GNOME)

On the Server

Follow these steps to start synergys when you log into GNOME. Go to System Menu > Preferences > Startup Applications. Click "Add" and enter synergys Click OK and Close.

Autostart Synergy before logging in (GDM)

Note: Autostarting Synergy before logging in requires that your network connection be available at all times and not just after you log in. This is accomplished by enabling the network connection for all users. To do this, choose System->Preference->Network Connections. Choose the network name and select Edit. Select "Available to all users", and then click "Apply". This connection will now be available at all times, including at the GDM login screen. To make sure synergy is running at all times, the following has to happen: First, synergy is started when the GDM login screen starts. Then, synergy is killed and restarted when a user logs in. When the user logs out, synergy is killed and GDM starts it again. To edit system configuration files in the following sections open a text editor as the root user:

sudo gedit

On the Server

At the end of the file /etc/gdm/Init/Default, just before the line that says exit 0 add the following:

/usr/bin/killall synergys
while [ $(pgrep -x synergys) ]; do sleep 0.1; done
/usr/bin/synergys

Add the following to the end of /etc/gdm/PostLogin/Default (create this file file if it does not already exist):

/usr/bin/killall synergys
while [ $(pgrep -x synergys) ]; do sleep 0.1; done

If you created the file, make sure it is executable with this command:

sudo chmod +x /etc/gdm/PostLogin/Default

Now, create a session file /etc/X11/Xsession.d/85synergys with the following contents

/usr/bin/killall synergys
while [ $(pgrep -x synergys) ]; do sleep 0.1; done
/usr/bin/synergys

Lastly, we must make the file executable with this command:

sudo chmod +x /etc/X11/Xsession.d/85synergys

On the Client

At the end of /etc/gdm/Init/Default, just before the line that says exit 0 add the following:

/usr/bin/killall synergyc
while [ $(pgrep -x synergyc) ]; do sleep 0.1; done
/usr/bin/synergyc <SERVER HOSTNAME>

Be sure to replace <SERVER HOSTNAME> with the host name or IP address of the computer running synergys. Add the following to the end of /etc/gdm/PostLogin/Default (create this file file if it does not already exist):

/usr/bin/killall synergyc
while [ $(pgrep -x synergyc) ]; do sleep 0.1; done

If you created the file, make sure it is executable with this command:

sudo chmod +x /etc/gdm/PostLogin/Default

Now, create a session file /etc/X11/Xsession.d/85synergyc with the following contents

/usr/bin/killall synergyc
while [ $(pgrep -x synergyc) ]; do sleep 0.1; done
/usr/bin/synergyc <SERVER HOSTNAME>

This will run synergyc when any user logs in. Be sure to replace <SERVER HOSTNAME> with the host name or IP address of the computer running synergys. Lastly, we must make the file executable with this command:

sudo chmod +x /etc/X11/Xsession.d/85synergyc

Autostart Synergy before logging in (KDM)

On the Client

Follow these steps to start the synergyc client when the KDM login screen launches. Add the following to the end of `/etc/kde3/kdm/Xsetup`:

/usr/bin/killall synergyc
sleep 1
/usr/bin/synergyc <SERVER HOSTNAME>

Be sure to replace <SERVER HOSTNAME> with the host name or IP address of the computer running synergys. For the client file we must also edit the Xstartup script to kill our synergyc process running as root before the user Xsession scripts run. To do this add the following to the end of `/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

See Also

Synergy Homepage QuickSynergy Homepage