Thursday, July 3, 2014

Share the keyboard and mouse on two X terminals - part 1/2

I have a desktop and a laptop on my workstation, side by side. No KVM switch. Each has its own display, mouse, and keyboard. I thought I could always slide over to use the other computer. Wishful thinking at its finest.

I started investigating KVM options. I like the idea of having both displays visible simultaneously. Therefore, the final solution only needs to share the mouse and the keyboard. Part 1 of this 2-part series focuses on x2x, a software KVM solution for 2 computers. Part 2 is on Synergy, a software KVM solution that supports more than 2 computers.

My primary machine is the desktop which runs Debian 7.5 (aka Wheezy). With x2x, I use the desktop's keyboard and mouse to control my secondary machine, the laptop which runs Ubuntu 12.04 (aka Precise Pangolin).

Installation

You only need to install x2x on the secondary machine, the one whose keyboard and mouse you are NOT using.

Before the install, verify that the X Server on your secondary machine supports the XTEST extension.

$ xdpyinfo -ext XTEST |grep XTEST XTEST XTEST version 2.2 opcode: 141

If the secondary machine runs on a recent Debian or Ubuntu release, the install is as easy as:

$ sudo apt-get install x2x

Unfortunately, recent Fedora and other Red Hat-based distributions do not pre-package x2x in their official repositories. This is not totally surprising because x2x is currently not being actively developed. Its most recent release was back in 2003. Part 2 of this series introduces an alternative tool named Synergy that works for Fedora.

If you are successful in installing x2x on a recent Fedora release, please share your experience by leaving a comment.

Setup

Before you run x2x, verify that X forwarding over SSH is enabled on the secondary machine. Specifically, the /etc/ssh/sshd_config file on that machine must contain the following line:

X11Forwarding yes

Restart the ssh daemon if you had to edit the sshd_config file.

$ sudo service ssh restart

For details on SSH X forwarding, please refer to my earlier post.

Running x2x

Execute a customized version of the following command on your primary machine, the one with the mouse and keyboard that you want to use.

$ ssh -X 192.168.1.111 x2x -west -to :0 peter@192.168.1.111's password:

The parameters to modify are:

  1. IP address

    This is the IP address of the secondary machine.

  2. Location of the secondary machine relative to the primary.

    My secondary machine is placed to the left of my primary, hence -west. When the mouse crosses the left edge of the primary display, the mouse pointer slides over to the secondary display. From there, when the mouse crosses the right edge of the secondary display, the mouse pointer slides back to the primary. Depending on the relative machine location, you can specify instead -north, -south, or -east.

Now, the two X displays are virtually integrated. Move the mouse of your primary display to the left, crossing the left edge. Notice that the mouse pointer lands in the secondary display. Any keystrokes you enter with the keyboard of the primary display appear inside a window on the secondary.

x2x is not currently under active development. But if your task is to share the keyboard and mouse between 2 Debian-based systems, x2x is a simple and effective solution. If you have more than 2 computers to share, or the computers are non-Debian, or even non-Linux (Mac OS X, Windows), consider using Synergy which is explained in the next post.

4 comments:

Anonymous said...

I've packaged x2x for fedora. You can find it in my copr repository. https://copr.fedoraproject.org/coprs/mmuzila/x2x/

Paul Striker said...

after the passwd x2x stops and says:

Usage: x2x [-to | -from ] options...
-copyright
-font
-geometry
-wait
-big
-buttonblock
-nomouse
-nopointermap
-north
-south
-east
-west
-nosel
-noautoup
-resurface
-capslockhack
-nocapslockhack
-clipcheck
-shadow
-sticky
-label
-title
-buttonmap " ..."

suggestions ?

Paul Striker said...

forgot to include the command:

ssh -X 192.168.106.119 x2x east -to :0

Paul Striker said...

problem solved... forgot to type a preceeding dash to the coordinate, sorry !