我相信相关的手册页是XKillClient。您可以xdotool像这样模拟从终端单击的关闭按钮。
例
假设我有一个gnome-terminal空地,它的名字是“ saml @ grinchy:/ home”。
获取窗口ID
$ xdotool search --name "saml@grinchy:/home"
96488188
 
发送给Alt+F4
$ xdotool windowactivate --sync 96488188 key --clearmodifiers \
     --delay 100 alt+F4
 
您可以通过将第一个命令嵌入第二个命令来将它们放在一起:
$ xdotool windowactivate --sync $( ...1st command...) key --clearmodifiers \
         --delay 100 alt+F4
您可以xdotool同时执行以下两项操作来保存自己:
$ xdotool search --name "saml@grinchy:~" key alt+f4
全球范围
您可以修改我提供的内容以在具有相同名称的Windows上运行它:
$ xdotool search --name "saml@grinchy:~"
96488779
96468996
或在Windows上按其他属性。您可以xwininfo用来查找有关特定窗口的更多信息。运行它,然后单击感兴趣的窗口:
$ xwininfo
xwininfo: Please select the window about which you
          would like information by clicking the
          mouse in that window.
xwininfo: Window id: 0x5c04d4b "saml@grinchy:~"
  Absolute upper-left X:  14
  Absolute upper-left Y:  74
  Relative upper-left X:  14
  Relative upper-left Y:  74
  Width: 941
  Height: 361
  Depth: 32
  Visual: 0x62
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x5c00003 (not installed)
  Bit Gravity State: NorthWestGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +14+74  -485+74  -485-465  +14-465
  -geometry 132x24+14+74
处理X11窗口时,其他有用的工具是xdpyinfo&xprop。xdpyinfo可用于查找有关X服务器的信息。因此,您可以找出哪个窗口具有焦点:
$ xdpyinfo |grep focus
focus:  window 0x5c00005, revert to Parent
xprop并xwininfo可以进行-id切换,因此您可以向他们提供您感兴趣的Window ID,而不必单击它:
$ xprop -id 0x5c00001|grep -i class
WM_CLASS(STRING) = "gnome-terminal", "Gnome-terminal"
参考文献
               
              
xdotool search --name "saml@grinchy:~" key alt+f4,问题是我还没有找到如何使用多个具有相同名称的窗口来执行此操作的方式