Wiki Ubuntu-it

Indice
Partecipa
FAQ
Wiki Blog
------------------
Ubuntu-it.org
Forum
Chiedi
Chat
Cerca
Planet
  • Pagina non alterabile
  • Informazioni
  • Allegati

Versione 10 del 26/02/2009 20.14.44

Nascondi questo messaggio

Indice(depth=1)

Introduzione

Synergy è un programma che permette l'utilizzo di una sola tastiera e di un solo mouse su più computer in rete. I computer possono avere sistemi operativi quali Linux, Windows o Mac OS. Il computer con la tastiera e il mouse è chiamato server, invece i computer che devono essere controllati da remoto sono detti client.

In questa guida sono presente istruzioni utili al corretto funzionamento di Synergy su una macchina con Ubuntu installato.

Sicurezza

Immagine(Icone/Piccole/warning.png,,center)

Il programma permetterà di effettuare operazioni che si possono rivelare insicure.

È possibile rendere Synergy più sicuro avviandolo con OpenSSH ma la procedura non verrà descritta qui.

QuickSynergy

È possibile ottenere un'interfaccia grafica per Synergy [:AmministrazioneSistema/InstallareProgrammi:installando] dal [:Repository/Componenti:componente] universe dei [:Repository:repository] ufficiali il pacchetto quicksynergy.

Avviare QuickSynergy su ogni computer. Nella macchina che funge da server inserire l'«hostname» dei computer, invece nei client inserire l'«hostname» o l'indirizzo IP del server e fare clic su «Start».

Installazione

Installazione da linea di comando

[:AmministrazioneSistema/InstallareProgrammi:Installare] il pacchetto synergy dal [:Repository/Componenti:componente] universe dei [:Repository:repository] ufficiali.

Compilare Synergy da sorgenti

Prima di iniziare assicurarsi di aver [:AmministrazioneSistema/InstallareProgrammi:installato] i pacchetti libxtst-dev e build-essential.

  1. Scaricare i sorgenti presso [http://synergy2.sourceforge.net/ questo indirizzo] nella propria cartella Home.

  2. Spostarsi con un terminale nella cartella appena scaricata e digitare i seguenti comandi:
    sudo ./configure -x-libraries /usr/lib -x-includes /usr/includes
    sudo make install
  3. Spostare gli eseguibili nella cartella /usr/bin, digitando i seguenti comandi:

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

Una volta terminata l'installazione è possibile rimuovere la cartella scaricata in precedenza e continuare con la configurazione.

Configurazione

Affinché ci sia un corretto funzionamento è necessario configurare sia il server che i vari client. In questa guida verrà trattata solo la procedura per configurare un computer con sistema Ubuntu.

Per la configurazione di Synergy su altri sistemi operativi, fare riferimento alla relativa [http://synergy2.sourceforge.net/index.html pagina].

Configurazione server

Le modifiche verranno effettuate nel file .synergy.conf presente nella propria Home. Di seguito è possibile visualizzare un esempio del suddetto file:

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

end

Il significato di ogni parametro è descritto nella seguente tabella:

Parametro

Significato

ubuntu42

È il computer principale che funge da server.

rossi

È il client che verrà gestito con tastiera e mouse

section

Campo in cui è possibile configurare le impostazioni

screens

Elenco degli hostname dei computer che si vogliono utilizzare

links

Imposta i collegamenti fra i vari computer.

In questo esempio il computer ubuntu42 è impostato sulla sinistra di rossi, quando si trascina il mouse sulla parte destra dello schermo del computer ubuntu42, il mouse apparirà nella parte sinistra dello schermo.

È possibile cambiare la posizione di scambio a proprio piacimento, inoltre si possono impostare più di due computer che, ovviamente, necessiteranno più collegamenti.

Configurazione client

La configurazione per i client non è necessaria. Le impostazioni saranno configurati automaticamente dopo l'installazione.

Utilizzo

  1. Dal server digitare in un terminale il seguente comando:
    synergys -f --config synergy.conf
  2. Se il programma viene avviato correttamente digitare il seguente comando:
    mv synergy.conf ~/.synergy.conf
  3. In questo modo Synergy può essere avviato digitando semplicemente il comando:

    synergys
  4. Da un client è necessario digitare il seguente comando:
    synergyc -f <indirizzo IP del server>

    Immagine(Icone/Piccole/note.png,,center)

    Il parametro «-f» avvia Synergy in primo piano, in questo modo è possibile visualizzare output di errori.

  5. Se la proceduta ha funzionato e si è in grado di muovere il mouse, digitare il seguente comando:
    synergyc <indirizzo IP del server>

Avvio automatico

GNOME

Per avviare Synergy all'avvio di Ubuntu senza dover utilizzare il terminale, è necessario andare su Applicazioni->Preferenze->Sessioni, fare clic sul tab «Programmi d'avvio» , fare clic sul tasto «Aggiungi» e inserire il seguente comando:

synergys --config synergy.conf

Questo permetterà di avviare il server in una sessione base dell'utente.

È possibile anche aggiungere un semplice script nella cartella /etc/X11/Xsession.d. 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/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/gdm/PreSession/Default and it should look like this:

#
# 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 '^BackgroundColor' /etc/gdm/gdm.conf | sed 's/^.*=\(.*\)$/\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!

#
# 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 '^BackgroundColor' /etc/gdm/gdm.conf | sed 's/^.*=\(.*\)$/\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:

# 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, GDM

To make sure synergy is running at all times, the following has to happen: First, synergy is started when the X server loads (before a user logs in). Then, synergy is killed and restarted when a user logs in. When the user logs out, synergy is killed and restarted. To make this happen under GNOME, the following must happen:

On the client

Edit /etc/gdm/Init/Default with the command

sudo gedit /etc/gdm/Init/Default

At the end of the file, after the last fi line but before the line that says exit 0 add the following:

# ADDED FOR SYNERGY
/usr/bin/killall synergyc
sleep 1
/usr/bin/synergyc <HOST NAME>
# END SYNERGY

Be sure to replace <HOST NAME> with the host name or IP address of the computer running synergys.

Then, edit /etc/gdm/PostLogin/Default with the command

sudo gedit /etc/gdm/PostLogin/Default

This will likely create a new file. Add the following to the file (placing the code at the end of the file if there's already stuff there):

# SYNERGY STUFF
/usr/bin/killall synergyc
sleep 1
# END

Now, create a session file to run synergyc when someone logs in with the following command

sudo gedit /etc/X11/Xsession.d/85synergyc

This will create a new file, place the following in the file:

/usr/bin/killall synergyc
sleep 1
/usr/bin/synergyc <HOST NAME>

Be sure to replace <HOST NAME> with the host name or IP address of the computer running synergys. Lastly, we must make the file executable with this command:

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

We're good to go with synergyc, the setup for synergys is almost identical:

For the server

Edit /etc/gdm/Init/Default with the command

sudo gedit /etc/gdm/Init/Default

At the end of the file, after the last fi line but before the line that says exit 0 add the following:

# ADDED FOR SYNERGY
/usr/bin/killall synergys
sleep 1
/usr/bin/synergys
# END SYNERGY

Then, edit /etc/gdm/PostLogin/Default with the command

sudo gedit /etc/gdm/PostLogin/Default

This will likely create a new file. Add the following to the file (placing the code at the end of the file if there's already stuff there):

# SYNERGY STUFF
/usr/bin/killall synergys
sleep 1
# END

Now, create a session file to run synergyc when someone logs in with the following command

sudo gedit /etc/X11/Xsession.d/85synergys

This will create a new file, place the following in the file:

/usr/bin/killall synergys
sleep 1
/usr/bin/synergys

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

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

We're good to go with synergys!

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.

Ulteriori risorse

http://quicksynergy.sourceforge.net


CategoryNuoviDocumenti CategoryInTraduzione