gnome-terminal - 如何通过在 linux 的另一个终端中发出命令来关闭 GNOME 终端?
问题描述
我在 Linux 中使用 gnome 命令打开了一个 gnome 终端作为新的不同窗口终端。现在我想要的是我只想通过在另一个终端中给出某个命令来关闭那个 gnome 终端。我尝试了一个命令作为“kill PID”,但是两个终端都关闭了。任何人都可以通过在另一个终端中编写命令来帮助我如何仅关闭 gnome 终端吗?
解决方案
使用“xdotool”将 alt+F4 发送到目标窗口。用您的 windowID 替换零:
xdotool windowactivate --sync 00000000 key --clearmodifiers alt+F4
您可以使用“xdotool search”来获取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
推荐阅读
- c# - 在 ASP.NET 页面上动态显示数据
- android - 房间中的总和和计数 - 别名没有这样的列
- jquery - 我在 laravel 5.3 中使用 twitter 引导程序,并且折叠功能在本地完美运行,但在实时服务器上却没有
- android - AndroidManifest 中的多个 ComponentDiscoveryService --> 合并冲突
- javascript - 在javascript中组合正则表达式
- azure - 具有持久功能的巨大 2 类队列操作计数
- c++ - 高斯模糊永远无法正常工作
- r - R中文件名列表中的矢量模式匹配和矢量替换
- sql - 两个模式之间的 Redshift 提取字符串 (regexp_substr)
- javascript - 修改父prototype.init()函数