How may I inject input to a terminal with terminator?

98 Views Asked by At

This is a specific question relating to use the terminator XTerm app for the general problem of inject or send shell command strings to a terminator panel. I am looking for a replacement for existing scripts that use xdotool to send command strings to the current terminal Tab/Panel. Under Wayland that would be a security violation (understandably). Naturally, xdotool is X-Org thing (not Wayland).

I thought of terminator because terminator lets me group panels and send the same command to each panel/session in the group. That tells me that terminator has the capacity and mechanism to send command strings to other panels.

I am questing for a method to use that ability to send input via stdin to a specific panel hosted by the same window. Perhaps beyond that to any open terminator panel using the same termiator parent/host or using a known DBus channel. I confess that it is a presumption that DBus could be used to succeeds in this objective.

I have not yet found a suggeston that this kind or ability is available. My first step is to ask if one of you knows of a way this can be done in a 'clean' way. It seems like the kind of 'need' or 'want' that a can be delivered with a plugin, if it doesn't exist yet. There are several questions about sending input to bash or terminal sessions. Not that I see as satisfactory. Most involve low-level stuff with seemingly inconsistient performance or manipulating screen or tmux and a bit suboptimal.

It struck me that the grouping feature of terminator is at least a demonstration of of one shell script (session) sending to another shell session instance. Although not necessarily how my xdotool scripts operate. Here a couple of examples to flesh-out what this

Use cases

  1. A launch script -- A terminal session used for a bit of workflow to (say) run make to build an app can launch the editor to open key files, open terminal to monitor the log and input and output, etc.
  2. Automate testing on CLI programs
  3. Auto start terminal sessions (along with #1).
  4. Automate -CLI based conversations
    • One notion here is for one script to send input to another terminal session,
    • Said sender can monitor output from redirect-ing stdout
  5. Launch (GUI) apps via the console/teminal.

The common need here is to have 'something' running independently under a different terminal session/panel.

Best case here is that the facility exists and I just haven't found the "How to" yet or that there's already a plugin that I can use or adapt/extend. I do not mind looking into writing a plugin if that's the only way. I would probably need to find a collaborator or two; do mention if you think this is something you'd like to see.

1

There are 1 best solutions below

0
will On

It appears that the easiest method is to use a terminator profile and/or layout. This 'ask ununtu' question has some tips:

I also did some other testing and found the outcomes to be inconcsistient witht he documentation. In the cited question they mention the bash rule; that is so. If you want the tab to stay open it must end with a bash or shell instance.

Of special mention the --execute <command> option seemed like the natural approach to adopt.

It can work with the terminator command as long as the incantation is worthy. I don't think I'm being ironic either. I have not yet managed to get --execute toer work consistiently with the remotinator tool, however, alas.

I'm interested in better suggestions, so I won't "tick" this answer just yet. Perhaps a future terminator release will tidy-up things and fulfill the promise in the documentation.