我已经在Linux中使用gnome命令将gnome终端作为新的其他窗口终端打开。现在我想要的是,我想通过在另一个终端中发出某个命令来仅关闭该gnome终端。我曾尝试使用“ kill PID”命令,但是两个终端都关闭了。任何人都可以通过在另一终端上写命令来帮助我如何仅关闭gnome终端吗?
使用“ xdotool”将alt + F4发送到目标窗口。用windowID替换零:
xdotool windowactivate --sync 00000000 key --clearmodifiers alt+F4
您可以使用“ xdotool搜索”来获取windowID。在引号之间插入终端标题:
xdotool search --name "text_to_search"
加入所有命令:
xdotool windowactivate --sync $(xdotool search --name "text_to_search") key --clearmodifiers alt+F4
如果需要,请添加“ --delay 100”以获得更好的性能。要安装“ xdotool”,请输入:
sudo apt-get install xdotool