7

I'm running Ubuntu Linux. I have two open Terminal windows running side by side. I'm looking to be able to hit the enter key once, and have that key stroke sent to both windows.

(What I'm doing is stepping through some code on two different systems using a debugger, and I don't want to have to keep switching back and forth between the windows as I step through the code.)

Thanks!

5 Answers 5

3

I don't see an easy way to do this while inside one of your debugging windows, but you could use a third windows running a script that wrapped around xvkbd. It's in the ubuntu repository (might be in universe). The script could read your keyboard input and then call xvkbd twice, sending the keystrokes to both windows. Normally a graphical program, using

xvkbd -window xterm2 -text $foo

sends key events to specific windows, but doesn't invoke a UI. You also might find that wmctrl helps identify windows & stuff. A simplistic script might be:

#!/bin/bash

while [ 1 ]; do
    wmctrl -i -a 0x02200003   #forcibly set focus in window running script
    read keys
    xvkbd -window 0x2202ea4 -text "$keys\r"
    xvkbd -window 0x2200084 -text "$keys\r"
done
2
  • 1 = 1 is not necessary, while [ 1 ] does the same thing :P
    – user1931
    Dec 13, 2009 at 6:09
  • I used this approach to control two Evince windows displaying two versions of the same PDF document. For some reason one of the windows missed about every 10th keystroke. I couldn't figure out why that was.
    – akaihola
    Feb 10, 2010 at 9:57
2

You'd not be able to do that in GNOME Terminal, IIRC.

If you'd like to try Konsole, there's a Send Input to All Sessions option in Konsole 3, which becomes Copy Input to... in Konsole 4.

2
  • 1
    I tested ny example script in gnome-terminal. worked ok. Dec 14, 2009 at 1:51
  • 1
    With the built-in fuctions of GNOME Terminal, I mean. :-)
    – 0x44
    Dec 14, 2009 at 4:42
2

The Terminator application (not to be confused by a Java application with the same name) provides exactly the functionality you need. You can install it from Ubuntu's repositories with apt-get install terminator.

Here's how it works:

  • run Terminator
  • open multiple sessions in tabs or frames
  • click the button at the top left corner of a frame
  • select the "New group..." menu item
  • type a name for the group
  • in each session you want to send keystrokes to, select that group from the menu
  • you can use the "Broadcast group" and "Broadcast off" menu items to toggle broadcasting keystrokes.

There are also keyboard shortcuts for this.

1

Use keyboardcast, which is designed for this.

1

Besides clusterssh, which is basically designed to do this but insists on spawning its own terminals, you can use xlax, which is a generic solution to distribute/send keystrokes to multiple X11 windows. It’s not packaged yet, but I will do that, as I needed “something like clusterssh, just for virt-manager” right now, and found this to be my tool of choice.

You must log in to answer this question.