Posts › Configuring Raspberry Pi and Synergy

2019-04-21

Previously, we described why we would want to use these extra tools in a daily development process. In this post, we will show you the exact steps needed to build a basic system that consists of a Raspberry Pi (any model will do, in our case we've used a model Zero W) connected to a main computer (such as a MacBook) via Wifi, sharing the mouse and keyboard via Synergy, and displaying to a LCD monitor via HDMI.

Purchasing hardware

You can either opt for a Raspberry Pi Zero with integrated Wifi or cheaper one without. This is the minimum hardware required:

Item                    Cost (GBP)      Link

Raspberry Pi Zero W     11.30           https://thepihut.com/products/raspberry-pi-zero-w
16GB microSD card       3.34            https://www.amazon.co.uk/gp/offer-listing/B079H6PDCK       
MiniHDMI adapter        1.00            https://www.ebay.co.uk/itm/173637998004    
--------------------------------------------------------------------------------------------
TOTAL                   15.64


        OR
        
        
Raspberry Pi Zero       7.65            https://thepihut.com/products/raspberry-pi-zero

MicroUSB OTG adapter &  1.13            https://www.ebay.co.uk/itm/153447624953
MiniHDMI adapter

USB wifi adapter        1.00            https://www.ebay.co.uk/itm/183750479953
16GB microSD card       3.34            https://www.amazon.co.uk/gp/offer-listing/B079H6PDCK       
--------------------------------------------------------------------------------------------
TOTAL                   13.12

You will also need some means of powering the RPi0, either use your LCD display's USB plugs if available or use a 5V/2A mains power to microUSB adapter. These can easily be found refurbished or lot sale LCD monitors with self-powered (monitor powered) USB hubs for powering the Pi. For example, a HP Compaq LA2405x 24-inch LCD which sells for £63 in April 2019.

Installing Raspbian

  1. Download the latest Raspbian Lite image
  2. Flash the image onto a microSD card (preferably 8GB or higher) using the official Raspberry Pi Imager or Etcher
  3. Once the microSD card is mounted and displayed as a drive on your system, add a wpa_supplicant file corresponding to your Wifi network into the root directory of the SD card.
  4. Create an empty ssh file in the same root directory: touch /Volumes/boot/ssh (on MacOS)
    This enables the SSH server on first-startup of the Pi.
  5. Replace your config.txt file to disable any optional hardware access.
  6. Put the microSD card into the Pi and power it on. Once the green light stops blinking, run ssh [email protected] to log in with password "raspberry".
  7. With raspi-config, change your hostname to something unique so you may identify it locally, e.g. jimspi
  8. Whilst inside, enable the SSH server so that it auto-starts on boot and finally, change your default password to something more secure.
  9. Follow this guide to install a minimal Raspberry Pi Desktop (RPD) on top of the installation of Raspbian Lite.

Installing Synergy

RPD is based on LXDE, following these steps will set us up correctly under this environment.

  1. sudo apt-get install synergy vim
  2. Create a file called synergy.host and write the IP of your Synergy host here.
  3. Create a script that will allow the pi to connect to the correct IP initSynergy.sh: we'll reuse this for startup as well as host IP changes.
#!/bin/bash
killall synergyc
# Ref: https://unix.stackexchange.com/questions/122845/using-a-b-for-variable-assignment-in-scripts
# Replace jimspi with the name of your own Raspberry Pi
synergyc --daemon --name jimspi --restart "${1:-$(cat synergy.host)}"

# Make this the new default host
if test -z "$1"
then
	echo "$1" > synergy.host
fi

Allow it to be executed by running:

chmod +x ./initSynergy.sh

Now create an auto-start entry:

sudo vim /etc/xdg/lxsession/LXDE-pi/autostart

then add this to the end:

@sudo /home/pi/initSynergy.sh

Configure boot options to automatically login to the Desktop on startup:

  1. Run sudo raspi-config
  2. Go into "3 Boot Options"
  3. Select "B1 Desktop /CLI"
  4. Select "B4 Desktop Autologin"

Finally we need to run sudo reboot. After this restart your system is ready for use.

Using initSynergy.sh

In the next post, we will go over how to show the Pi's IP on the desktop, and performance tweaks allowing your Pi run more programs with less system resources.

Simplify and consolidate your computing systems

Cohesive.dev provides comprehensive software, operating system, and network configuration audit services to ensure your computing resources continue to work reliably and efficiently. Improve your system setup by contacting us today.