外部コマンドでターミネーターを分割しますか?

外部コマンドでターミネーターを分割しますか?

gnome-pie または類似のものからターミネータにフレーム (タブではない) を追加できるようにしたいと思います。「--help」では何も表示されないようですが、皆さんは何かありますか?

答え1

任意のキーの組み合わせをシミュレートするには、ツールを使用するのが思い浮かびますxdotool

インストール$ sudo apt-get install xdotool

使用法:

$ xdotool key [key]+[key]

例えば

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

これを使用すると、エイリアスの作成が簡単になります。

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

ここに画像の説明を入力してください

試してみる。

アップデート

わかりました。解決策を見つけましょう。

他の端末からコマンドを実行するユーティリティを見つけましたここ。

ファイルを作成し$ vim ttyecho.c、このコードをコピーします

#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);
}

次にmake+ファイルを実行します

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

さあ試して、ターミネーターターミナルでチェックしてくださいtty

$ tty
/dev/pts/0

他の端末で以下を実行します

$ ttyecho -n /dev/pts/0 splith

答え2

これはtachomiの優れた答え; ぜひ投票してください。

私の知る限り、ターミネーターを (例えば) 外部 DBUS コマンドで分割する方法はありません。そのため、他の回答で提案されているように、キーストローク ハックを使用する必要があります。ターミネーターにキーストロークを送信するには、まずアクティブになっていることを確認する必要があります。これを行う 1 つの方法は次のとおりです。私の場合、ターミネーターを常時オンの「ポップアップ」ターミナルとして使用し、Ctrl+でアクティブにします。私のスクリプトは、それが非表示になっているかどうかを確認し、 +Spaceをエミュレートして表示します。そうでない場合、表示されているが前面にない場合は、ウィンドウをアクティブにします。CtrlSpace

ポップアップ ターミナルとして使用しない場合は、おそらくこれで動作するはずなので、その条件を決して実行しないでください。

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

このスクリプトを実行してウィンドウをアクティブにした後、他の回答に従ってコマンドを実行します。つまり、次のいずれかを実行します。 (詳細については、を参照)xdotoolを使用することをお勧めします。--clearmodifiersman xdotool

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

答え3

最近は以下が使えますremotinator hsplit:https://terminator-gtk3.readthedocs.io/en/latest/advancedusage.html#remotinator

今日これを探していたのですが、他の誰か(または将来の私)がこの投稿を見つけた場合に備えてここに投稿します。

関連情報