Share a Keyboard/Mouse Between Multiple Computers With x2x
If you have multiple computers on your desktop there are a number of scenarios for using them:
- The brute force way: get a big desk and a swivel chair and spin back and forth between keyboards/mice
- Use VNC or rdesktop to control secondary computers from your primary computer. The main problem with this is that you lose all the screen real estate on your secondary computers and end up with their desktops showing in a window on your primary computer.
- Get a KVM to allow you to switch one keyboard/mouse between multiple
The normal usage of a KVM is to switch your monitor as well as your keyboard and mouse, but that's not required. KVM's often seem like a great solution for many peripheral sharing problems, but they're a bit of a hit-or-miss. They often have switching problems, system boot problems, video quality problems, and if you use multiple monitors a KVM to switch multiple monitors between systems gets pretty expensive.
- Use x2x, the solution we'll examine here, to share the keyboard and mouse between systems.
There are two ways to run x2x on Linux, the easiest is to use ssh with X forwarding enabled and ssh from the primary system to the secondary system and run x2x on the secondary system:
primary $ ssh -X secondary x2x -east -to :0
The -X option tells ssh to enable X forwarding. The "x2x ..." tells ssh to run x2x on the remote system (secondary) rather than running the shell. The "-east" option tells x2x where one system is relative to the other: to the east or west (-west).
The primary system is the system whose keyboard and mouse you are actually using. The secondary system is the one that is going to share the primary system's keyboard and mouse.
Now, if you move the mouse on the primary system over to the edge where the secondary system is the mouse pointer should move from the primary screen to the secondary screen and from now on any mouse movement should be passed to the secondary system and anything you type on the keyboard should be sent to the secondary system. If this doesn't work try moving the mouse to the other side of the screen, if that works then restart the command using "-west" rather than "-east".
The other method of running x2x on a Linux system is to run it directly on the primary system and tell it to connect to the X server on the secondary system:
primary $ x2x -to secondary:0.0 -east
The reason this is not the easy method is that you also need to enable remote X access on the secondary system using xhost:
secondary $ xhost primary
and you also need to open TCP port 6000 on both systems. The easiest way of doing this is going to depend on your distro.
The main advantage of the second method is that copy/paste will now work between systems.
Getting x2x to work on a Windoze system takes a bit more work, mostly because first you have to install Cygwin. Although, if you're a Linux fan you should already have it installed, it's the only way to make Windoze bearable. When you're installing Cygwin make sure x2x is selected in the list of available packages.
Using x2x with Cygwin has a couple of restrictions/problems:
- You can't use the ssh connection method.
- You have to use the Windoze system as the primary system (i.e. you have to use the keyboard and mouse on the Windoze system).
- If you have multiple displays on your Windoze system you'll probably experience mouse problems when you return the mouse from a secondary display. The only workaround is to move the mouse very very slowly when you're about to move off a secondary display onto the primary display.
When using x2x on Windoze run the following command from a shell prompt:
windoze $ x2x -fromwin -to secondary:0.0 -east
Generally speaking x2x works very well both on Linux and on Windoze. Every once in a while you may get a bit of mouse flakiness when you move a window on a secondary display. Also once in a while, when using the shift key you may get the unshifted character on the secondary system if you type too fast. But in most instances you won't notice any difference between typing/mousing on the primary system and on the secondary system.
p.s. If you have a problem where you get a ">" when you type "<" you need to find a newer version of x2x. This is long-standing bug that was recently fixed.
Mitch Frazier is an Associate Editor for Linux Journal.
|Happy Birthday Linux||Aug 25, 2016|
|ContainerCon Vendors Offer Flexible Solutions for Managing All Your New Micro-VMs||Aug 24, 2016|
|Updates from LinuxCon and ContainerCon, Toronto, August 2016||Aug 23, 2016|
|NVMe over Fabrics Support Coming to the Linux 4.8 Kernel||Aug 22, 2016|
|What I Wish I’d Known When I Was an Embedded Linux Newbie||Aug 18, 2016|
|Pandas||Aug 17, 2016|
- Happy Birthday Linux
- ContainerCon Vendors Offer Flexible Solutions for Managing All Your New Micro-VMs
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Updates from LinuxCon and ContainerCon, Toronto, August 2016
- What I Wish I’d Known When I Was an Embedded Linux Newbie
- New Version of GParted
- NVMe over Fabrics Support Coming to the Linux 4.8 Kernel
- Tor 0.2.8.6 Is Released
- All about printf
- Blender for Visual Effects
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide