blog · git · desktop · images · contact


Typing into multiple X11 windows at once

2017-03-04

Cluster SSH is a well-known project. Short description: You can use it to open SSH connections to multiple hosts and then type on all hosts simultaneously.

Problem is, you have to know that in advance. You can’t just “convert” an existing SSH session in your regular terminal into a cluster SSH session. I guess this is one of the reasons why a similar feature exists in some terminal emulators, for example in Terminator. It’s a regular terminal, but you can – on the fly – group some terminal windows and type simultaneously. That’s much better.

What still bothers me is that I have to use Terminator now. Can’t I keep using whatever I’m using right now? Isn’t there some kind of generic solution to this problem?

There might have been. Once. A tool named keyboardcast. It was written around 2005 and I can only find sources from Ubuntu. The project’s actual homepage appears to be dead.

Very well, looks like I have to do this myself. “How hard can it be?”

Here you go:

This tool doesn’t know anything about terminals or SSH. It’s just a generic X11 key event proxy. As a result, it’s a rather short C program of about 300 lines.

Start it and click on a window to select it. Repeat with some other window. A right-click ends selection mode. Then type some text while multipass still has focus. Tada, all selected windows receive the same input.

ssh

Due to this generic approach, you can easily mix clients …

mixed clients

… even though multiple terminals with SSH connections will probably still be the most common use case.

A short screencast showing multipass in action.

— Captain’s log, supplemental. After I finished writing my tool (and this blog post), I found “xduplic-copier” which is part of chiark-utils – it’s even older, written 15 years ago in 2002. It looks very similar to my tool, but I didn’t get it to work. Just won’t relay any keystrokes. Didn’t do any debugging, because it doesn’t show the window titles of selected clients – it only show “five clients selected”. Well, which ones? :-) Its way of selecting windows is much better, though. I adopted that.

Comments?