2

I have variable stand alone shell routines which I execute one after another automatically. Since every routine produces several X-windows figures I want to close all of them at the end without modifying every single routine. Is there a certain command?

Cheers!

Barett
  • 5,826
  • 6
  • 51
  • 55
MichaelScott
  • 387
  • 1
  • 3
  • 21

2 Answers2

2

Based on answers to this question. xdotool looks like what you need.

To kill an X11 window given it's title, you can use:

xdotool search "Your window title here" windowkill 
Community
  • 1
  • 1
Richard Neish
  • 8,414
  • 4
  • 39
  • 69
  • From the manpage: `windowclose` will close the window but not kill the controlling application, `windowkill` will kill the controlling application. So, `windowclose` will act like hitting the "close"-button on the window and the application can exit nicely, `windowkill` will be more like `xkill`. More refined search for window names I get with `xlsw` instead of `xdotool`, example: `xlsw | grep 'Firefox/Popup' | awk '{print $1}' | while read i; do xdotool windowclose "$i"; done`; `xdotool search` would miss the `/Popup`-part in the name. – Golar Ramblar May 31 '17 at 08:34
0

Windows are owned by processes. One way to close windows is to kill their owner processes.

Another way is to start another X server, run your scripts with DISPLAY environment variable referring to the display of that X server, then terminate that X server with all windows.

Maxim Egorushkin
  • 131,725
  • 17
  • 180
  • 271