One issue we sometimes find with the Raspberry Pi is the lack of USB ports. We don’t always have the luxury of using a powered USB hub, and it can become a bit of a hassle to juggle a mouse and keyboard with other devices. Instead of using a hardware solution for this, you can always try a software solution – one that opens up the uses of the Raspberry Pi as well. The Synergy program lets you share the mouse and keyboard of one system with other systems on the same network, acting as a virtual KVM. In this tutorial we’ll learn how to use your main computer’s input devices on your Raspberry Pi, as well as how you can look into making it a server.
Latest Raspbian Image
Step 01 Install Synergy
Synergy is available from the Raspbian repositories. We can install it by using the following:
$ sudo apt-get update $ sudo apt-get install synergy
This will go through the basic installation process as normal and Synergy will be put in the Accessories folder.
Step 02 Start up Synergy
Start up Synergy on the host computer and choose the ‘Server’ option for the moment. We’ll cover how to use it as a client later, and how to use the Raspberry Pi as a server for the mouse and keyboard.
Step 03 Encryption and passwords
Here, you can set up whether or not the connection is encrypted. This is useful for stopping key loggers from being able to snoop on your information, or random clients from connecting and hijacking your mouse. Provide a password and then click Finish.
Step 04 Server naming
Once the process has finished, go to Configure Server. Your host computer will be put virtually in the centre of your array of displays and you can drag and drop it around, along with any connected screens. Double-click on the server to change its name, making it easier to remember and find. Add a new screen and call it pi.
Step 05 Starting and connecting
Once you’re happy with the setup, click Start to be able to accept client connections. To connect from a Raspberry Pi, enter the following:
$ synergyc --name pi [IP Address of host]
It will be recognised as ‘pi’ on the host system.
Step 06 Autostart Synergy
To make sure it starts every time you turn on the Pi, we need to create an LXDE autostart file by using the following:
$ sudo mkdir -p ~/.config/lxsession/LXDE $ sudo touch ~/.config/lxsession/LXDE/autostart $ sudo nano ~/.config/lxsession/LXDE/autostart
And then add the following to autostart:
Step 07 Start file
Open and populate the startsynergy file with:
$ sudo nano ~/.startsynergy.sh #!/bin/bash killall synergyc sleep 1 synergyc --name pi [IP address of host] exit 0
Step 08 Permissions
Finally, to finish it off you’ll need to run:
sudo chmod 777 ~/.startsynergy.sh
This will autostart, and hopefully autoconnect, Synergy whenever you turn it on. The Raspbian client is a little old, so if you get a problem you may need to compile the latest version from source.
Step 09 Pi server
Setting up the Raspberry Pi as a server is a little more involved and uses the synergys command. It allows you to listen for clients on specific addresses. You then need to create a separate configuration file to arrange the displays – however, you can load one from a different computer and edit it.