
Ich möchte in der Lage sein, Frames (keine Tabs) zum Terminator von Gnome-Pie oder etwas Ähnlichem hinzuzufügen. „--help“ schien nichts zu ergeben, aber habt ihr was?
Antwort1
Um eine beliebige Tastenkombination zu simulieren, fällt mir nur die Verwendung xdotool
eines Tools ein.
Installieren$ sudo apt-get install xdotool
Verwendung:
$ xdotool key [key]+[key]
z.B
$ xdotool key ctrl+shift+o # To split horizontal
$ xdotool key ctrl+shift+e # To split vertical
Dadurch wird die Erstellung einiger Aliase vereinfacht.
$ alias splith='xdotool key ctrl+shift+o'
$ alias splitv='xdotool key ctrl+shift+e'
Versuche es.
AKTUALISIEREN
Ok, lasst uns eine Lösung finden.
Ich habe ein Dienstprogramm gefunden, um Befehle von anderen Terminals auszuführen inHier.
Erstellen Sie eine Datei $ vim ttyecho.c
und kopieren Sie diesen 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);
}
Dann ausführen make
+ Datei
$ make ttyecho
$ sudo chown root:root ttyecho
$ sudo cp ttyecho /usr/bin
Probieren Sie es jetzt aus, überprüfen Sie im Terminator-Terminaltty
$ tty
/dev/pts/0
Führen Sie in einem anderen Terminal Folgendes aus
$ ttyecho -n /dev/pts/0 splith
Antwort2
Dies ist ein Nachtrag zu tachomis ausgezeichnetemAntwort; bitte geben Sie ihm eine positive Bewertung.
Soweit ich weiß, gibt es keine Möglichkeit, Terminator mit (z. B.) einem externen DBUS-Befehl aufzuteilen, daher müssen Sie einen Keystroke-Hack verwenden, wie in der anderen Antwort vorgeschlagen. Um Terminator die Tastenanschläge zu senden, müssen Sie zuerst sicherstellen, dass er aktiv ist. Eine Möglichkeit, dies zu tun, ist wie folgt. In meinem Fall verwende ich Terminator als ständig aktives „Popup“-Terminal, das mit Ctrl+ aktiviert wird. Mein Skript prüft, ob es ausgeblendet ist, und lässt es dann durch Emulieren von + Spaceerscheinen . Andernfalls aktiviert es das Fenster, wenn es sichtbar, aber nicht im Vordergrund ist.CtrlSpace
Wenn Sie es nicht als Popup-Terminal verwenden, sollte es wahrscheinlich trotzdem funktionieren, und Sie sollten diese Bedingung einfach nie durchlaufen.
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
Nachdem Sie dieses Skript ausgeführt haben, um das Fenster zu aktivieren, führen Sie einfach die xdotool
Befehle gemäß der anderen Antwort aus, also einen der folgenden. Ich würde auch vorschlagen, --clearmodifiers
( man xdotool
weitere Informationen finden Sie unter) zu verwenden.
xdotool key --clearmodifiers ctrl+shift+o
xdotool key --clearmodifiers ctrl+shift+e
Antwort3
Heutzutage können Sie Folgendes verwenden remotinator hsplit
:https://terminator-gtk3.readthedocs.io/en/latest/advancedusage.html#remotinator
Ich habe heute danach gesucht und poste es hier nur für den Fall, dass jemand anders (oder mein zukünftiges Ich) diesen Beitrag auch findet.