Build a Large-Screen Command Center with the RPi 2

Mouse and Keyboard Sharing

Because I have both RPis running in graphical mode, I need a keyboard and mouse, but in the NYSERNet, Inc., command center, eliminating clutter is an important goal. When it came time to control the RPis, I didn't want a bunch of keyboards and mice lying around. I wanted just one of each, and I wanted those to control the two computers wirelessly. The answer was SSH and its x2x feature. (See Resources for a full Linux Journal x2x how-to.)

With x2x, you can move the mouse (and keyboard focus) from one RPi to the other, one monitor to the other, as though the screens were attached to a single computer. It's fast and seamless.

I attached a Bluetooth USB dongle to the primary RPi I called rpi01. It was immediately detected by the system and connected my Bluetooth keyboard and mouse. I tested the functionality with the window manager, and everything worked fine, although I needed to adjust the mouse speed a bit so it would traverse the vast desktop more quickly.

The RPi is friendly to most modern Bluetooth USB adapters, so you should be able to get one to be plug-and-play. From there, you'll want to share the mouse and keyboard with your secondary RPi (in my case, rpi02). Since rpi01 was my "primary" RPi, and I wanted to connect to rpi02, my "secondary" RPi located to the left (or -west) of the other, I opened a terminal on rpi01 and entered the following:


pi@rpi01:~$ ssh -X pi@rpi02 x2x -west -to :0

This example assumes you're logged in to your primary RPi as the user pi and you want to connect to your secondary RPi as the user pi. Another way of putting it is this: if your Bluetooth mouse and keyboard are working on rpi01 and you want to connect to rpi02 at 192.168.1.11, issue the command:


pi@rpi01:~$ ssh -X pi@ 192.168.1.11 x2x -west -to :0

The :0 indicates the primary display. Once connected, the mouse now will move seamlessly from one screen to the other, and the focus for the keyboard will follow. If you want, you can create a script and drop it on the desktop of the primary RPi so you quickly can run SSH x2x after a reboot.

For those who want to do this from two or more systems that don't use Linux, Synergy is a good choice. It's a $10 application that works across Linux, Mac and Windows.

Set Up VNC as a Remote-Control Alternative

If you'd rather not have any keyboard and mouse cluttering your public space where you plan to hang your monitors (or because you just don't use them with the RPis very much), a good alternative to SSH x2x is VNC.

It used to be rather difficult to set up VNC on Linux and access the active session, but that changed with the advent of the vino package. Now, in-session VNC works right out of the box with a simple graphical control panel.

Use your package manager to install vino on each target RPi. Once installed, open a terminal and run the vino setup utility:


$ vino-preferences

Figure 8. VNC Desktop Sharing Preferences

Under Sharing, enable both "Allow other users to view your desktop" and "Allow other users to control your desktop". Uncheck "You must confirm each access to this machine", so you don't have to acknowledge the connection on the target RPi. Also check "Require the user to enter this password", and enter a password to thwart any unauthorized access.

Click close and reboot the RPi. This will ensure that vino-server will start. In future boots, vino-server will start automatically. Again, the goal here is to set up these RPis so you can do everything remotely and not have to log in to start basic services.

Once the RPi reboots, repeat the vino package install and setup on any additional RPis you're using, then go to your desktop and install a VNC-compatible remote-desktop client. There are many options for all platforms, but I prefer Remmina on my Linux Mint 17 desktop. Remmina supports VNC and RDP, and it makes it easy to throttle the graphical resolution and connection speeds to customize the remote-user experience.

Use your package manager to install Remmina. It comes with VNC support out of the box, but you also can install remmina-plugin-vnc manually.

Once installed, launch Remmina from the command line by entering remmina (or open the graphical control panel):


$ remmina

Create a new connection with appropriate parameters (Figure 9).

Figure 9. Creating a Profile

Create a profile for each RPi to which you want to connect. Give each profile a name, ensure that you've selected the VNC protocol, enter the server address for the RPi, use the default RPi account (usually pi unless you've changed it), and set the color depth and quality.

I used a color depth of 256 colors and "Poor" quality, because I wanted a better remote-user experience. If you get greedy with the color and quality, the RPi will struggle a bit to redraw and refresh the VNC window, which is about four times the size of a typical desktop monitor.

Click Save or Connect, and you'll connect to your RPi. Be patient. I've found that this connection is not instantaneous even across a fast LAN. It takes several seconds. Once connected, you can use Remmina to show a full-screen view and use its window sliders to navigate to areas of the RPi desktop that don't fit on your smaller desktop monitors.

Before hanging the new 50-inch TVs in our command center, I did my final testing with everything still on the ground. I booted each RPi, installed and launched the applications I needed, tested the networking and the remote connections, and left the whole thing running for a few days. Once I felt confident everything was stable, we hung the screens on low-profile wall-hangers, connected the RPis with the short HDMI cables and tucked them behind the TVs. Anyone looking sees only the monitors; the rest is neatly hidden away.

Final Thoughts

Because your RPis probably are sitting on a network, it's a good idea to secure them with a firewall. I set up some iptables rules that block almost all traffic.

Also, to make the RPis even easier to maintain, you may want to install Webmin, a free Web-based administration tool for Linux environments. It works well under Raspbian and doesn't hog resources when it's not in use.

Resources

NOOBS RPi Config: https://www.raspberrypi.org/documentation/installation/noobs.md

Config.txt Documentation: https://www.raspberrypi.org/documentation/configuration/config-txt.md

RPi Config Documentation: http://elinux.org/RPiconfig

Duplicate SD Card: https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=46911

Linux Journal x2x How-To: http://www.linuxjournal.com/content/share-keyboardmouse-between-multiple-computers-x2x

Synergy Mouse and Keyboard Sharing: http://www.synergy-project.org

______________________

John S. Tonello is Director of IT for NYSERNet, Inc., in Syracuse, New York. He's been a Linux user and enthusiast since he installed his first Slackware system from diskette 20 years ago. You can follow him @johntonello.