0

I'd like to be able to add frames (not tabs) to terminator from gnome-pie or something similar. "--help" didn't seem to have anything, but do you guys?

2

To simulate any key combination, what comes to my head is to use xdotool tool.

Install $ sudo apt-get install xdotool

Usage:

$ xdotool key [key]+[key]

e.g.

$ xdotool key ctrl+shift+o # To split horizontal
$ xdotool key ctrl+shift+e # To split vertical

Having this you can make it easier creating some aliases.

$ alias splith='xdotool key ctrl+shift+o'
$ alias splitv='xdotool key ctrl+shift+e'

enter image description here

Give a try.

UPDATE

Ok lets found a solution.

I found a utility to execute commands from other terminals in here.

Create a file $ vim ttyecho.c, copy this code

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <string.h>
#include <unistd.h>

void print_help(char *prog_name) {
        printf("Usage: %s [-n] DEVNAME COMMAND\n", prog_name);
        printf("Usage: '-n' is an optional argument if you want to push a new line at the end of the text\n");
        printf("Usage: Will require 'sudo' to run if the executable is not setuid root\n");
        exit(1);
    }

int main (int argc, char *argv[]) {
    char *cmd, *nl = "\n";
    int i, fd;
    int devno, commandno, newline;
    int mem_len;
    devno = 1; commandno = 2; newline = 0;
    if (argc < 3) {
        print_help(argv[0]);
    }
    if (argc > 3 && argv[1][0] == '-' && argv[1][1] == 'n') {
        devno = 2; commandno = 3; newline=1;
    } else if (argc > 3 && argv[1][0] == '-' && argv[1][1] != 'n') {
        printf("Invalid Option\n");
        print_help(argv[0]);
    }
    fd = open(argv[devno],O_RDWR);
    if(fd == -1) {
        perror("open DEVICE");
        exit(1);
    }
    mem_len = 0;
    for ( i = commandno; i < argc; i++ ) {
        mem_len += strlen(argv[i]) + 2;
        if ( i > commandno ) {
            cmd = (char *)realloc((void *)cmd, mem_len);
        } else { //i == commandno
            cmd = (char *)malloc(mem_len);
        }

        strcat(cmd, argv[i]);
        strcat(cmd, " ");
    }
    if (newline == 0)
        usleep(225000);
      for (i = 0; cmd[i]; i++)
        ioctl (fd, TIOCSTI, cmd+i);
      if (newline == 1)
        ioctl (fd, TIOCSTI, nl);
    close(fd);
    free((void *)cmd);
    exit (0);
}

Then execute make + file

$ make ttyecho
$ sudo chown root:root ttyecho
$ sudo cp ttyecho /usr/bin

Now try it, check in the terminator terminal tty

$ tty
/dev/pts/0

In other terminal execute the following

$ ttyecho -n /dev/pts/0 splith
  • Thanks, but I know about that. I want the same effect but with a command, something like terminator --new-tab but with frames. – Aido Feb 11 '16 at 21:50
  • @AidanEdwards I edited. – tachomi Feb 11 '16 at 21:54
  • But wouldn't that only allow me to do it in that terminal? – Aido Feb 11 '16 at 22:08
  • @AidanEdwards In the terminal space you're placed in – tachomi Feb 11 '16 at 22:15
  • I stated it my question, I want to be able to run it from outside of Terminator. – Aido Feb 11 '16 at 22:19
1

This is an addendum to tachomi's excellent answer; please upvote it.

AFAIK there is no way to split terminator with (e.g.) an external DBUS command, so you need to use a keystroke hack as proposed in the other answer. To send terminator the keystrokes, you need to make sure it's active first. One way to do this is as follows. In my case, I use terminator as an always-on "pop-up" terminal, activated with Ctrl+Space. My script checks to see if it's hidden, then makes it appear by emulating Ctrl+Space, otherwise if it's visible, but not in the front, it activates the window.

If you don't use it as a pop-up terminal, then this should probably work anyway, and just never go through that conditional.

windowlist=$(xprop -root | sed -rn 's/_NET_CLIENT_LIST_STACKING\(WINDOW\): window id # (.*)/\1/p' | tr -d ',')
terminator_visible=false
for i in $windowlist; do
  [[ $(xprop -id $i | grep WM_CLASS\(STRING\)) == 'WM_CLASS(STRING) = "terminator", "Terminator"' ]] && terminator_visible=true && term_id=$i
done

if [[ $terminator_visible == false ]]; then # it's hidden
  xdotool key --clearmodifiers ctrl+space
elif [[ $(xprop -id $(xdotool getactivewindow) | grep WM_CLASS\(STRING\)) != 'WM_CLASS(STRING) = "terminator", "Terminator"' ]]; then # it's visible, but not active
  xdotool windowactivate $term_id 2> /dev/null
fi

After running this script to activate the window, then just run the xdotool commands as per the other answer, i.e. one of the following. I'd also suggest using --clearmodifiers (see man xdotool for more information).

xdotool key --clearmodifiers ctrl+shift+o
xdotool key --clearmodifiers ctrl+shift+e

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.