⬆️ ⬇️

Synergy - one keyboard mouse on all computers

There is a wonderful synergy program. Allows you to use one set of keyboard-mouse with multiple computers. It is cross-platform, works on MS systems - both Windows and NT, on Mac OS X. Well, of course - on X11.



About synergy here already said , I will add a little.



Windows and OS X will not concern, I will pay attention only to X11.

')

The computer to which the keyboard is connected and the mouse acts as a server, it runs synergys . Other computers are clients — they run synergyc , which connects to synergys . By TCP, of course. All settings are made on the server side. The configuration describes the location of the server screens and clients relative to each other - right, left, top, bottom.



Installation in Debian-like systems:



  apt-get install synergy 


An example of the /etc/synergy.conf config. In the center is the computer main, laptop1 to its left, laptop2 to the right. All of them form a ring - when the pointer passes the left edge of the left screen, it is on the right edge of the right one.



  # /etc/synergy.conf
 #
 # Screens of all computers, including server
 # Named host computer names
 section screens
   main:
   laptop1:
   laptop2:
 end
 #
 # Mutual arrangement of screens
 section links
   main:
     left: laptop1
     right: laptop2
   laptop1:
     left: laptop2
     right: main
   laptop2:
     left: main
     right: laptop1
 end 


Starting the server using the synergys command.



Connection - synergyc ___ . If the host client name is different from what is written in the server config, then you can specify the -n _ parameter, where client_name is the name from the config.



The server works only in X, and only in the active X server - in that it accepts input from HIDs. If you switch to another console, including another X server, then synergys stops serving clients. Until the X server again receives the keyboard of the mouse.



When multiple users work on the same computer in turn, you can run synergys on each X server, including the one running GDM. Each synergys uses its own TCP port, and as for the config, one for all is enough. The default port is 24800. To specify a port, use the -a [][:] key. Example: synergys -a :24801 . Address not specified - listens on all interfaces.



Synergy is not very secure. All keystrokes are transmitted in clear text, there are no encryption mechanisms embedded. SSH with forwarding ports will come to the rescue. Local Forwarding. You can read about forvarding man ssh and the article SSH Port Forwarding .



Ssh starts first:



  ssh -f -L24800: server_name or server_address: 24800 server_name or server_address sleep 10 


Local port 24800 is forwarded to server port 24800. ssh went to the background (the -f ) and performs sleep 10 on the remote side. In these 10 seconds, you need to have time to run synergyc , otherwise ssh will exit.



  synergyc localhost 


Now about usability. If the server can be started when X starts up automatically - by typing in .xsession, or, in accordance with today's fashion, by clicking the mouse in the GNOME / KDE / XFCE / LXDE control center, then it’s more difficult with the client. It is better to run it interactively.



There is quicksynergy utility. Iksovaya, more precisely - under GTK. So here. I do not like her. In order to start the client, go to the tab, enter the server name, click “run”, then click “close” so that it hides in the tray. Remembers only the last server entered. Tray icon too healthy - striking. ssh can not run. In general - a terrible thing. I do not use it.



I wrote my script to start and stop the client. Normal shell script. On my computer, this script is called ~ / bin / syn



When started without parameters, ~/syn gives a brief usage help.



Configuration in the text of the script. The case $TARGET in block, coming immediately after the comment # Start user configurable settings .



Configuration example The name of the first host, home, for example - main.example.com, on it two X servers - 2 users work. Accordingly - two synergy servers. The name of the second host, for example, at work is second.example.com. There is one X server. Local ports must be different so that several clients can be started simultaneously.



  # ...
 # Start user configurable settings
 case $ TARGET in
   d1)
     # First host, first X server
     SYN_LOCAL_PORT = 24800
     REMOTE_HOST = 'main.example.com'
     SYN_REMOTE_PORT = 24800
   d2)
     # First host, second X server
     SYN_LOCAL_PORT = 24801
     REMOTE_HOST = 'main.example.com'
     SYN_REMOTE_PORT = 24801
   w)
     # Second host
     SYN_LOCAL_PORT = 24802
     REMOTE_HOST = 'second.example.com'
     SYN_REMOTE_PORT = 24800
 # ... 


Also, it's a good idea to fix the Defined tragets line of the usage function with which the script starts.



Client Start:



  $ ./bin/syn d1 start
 Starting: 'ssh -f -L24800: main.example.com: 24800 main.example.com sleep 10' .. done.
 Starting: 'synergyc 127.0.0.1:24800' .. done. 


View the status of a running client:



  $ ./bin/syn d1 status
 Checking ssh process: 'ssh -f -L24800: main.example.com: 24800 main.example.com sleep 10' .. running, PID 18503.
 Checking synergyc process: 'synergyc 127.0.0.1:24800' .. running, PID 18505. 


Kill the client:



  ./bin/syn d1 stop
 Killing: 'synergyc 127.0.0.1:24800' .. done
 Killing: 'ssh -f -L24800: main.example.com: 24800 main.example.com sleep 10' .. done. 


View the status of an un-started client:



  ./bin/syn d1 status
 Checking ssh process: 'ssh -f -L24800: main.example.com: 24800 main.example.com sleep 10' .. stopped
 Checking synergyc process: 'synergyc 127.0.0.1:24800' .. stopped.


PS To quickly launch something from the command line, I use a tilde tied to the <Alt ~> keys.

Source: https://habr.com/ru/post/85828/



All Articles