How to close only one window of an application?
Probably the easiest option is using wmctrl -c
. You might have to install it first:
~$ sudo apt-get install wmctrl
then to close a window named "example" (no matter what application it belongs to), use the command:
~$ wmctrl -c "example"
More options
However, there are many more options to close a specific window, depending on your "angle of incidence".
A few examples:
-
To close a specific window by clicking on it:
~$ wmctrl -c :SELECT: [then click on the window to be closed]
-
To close a specific window by its numeric id:
~$ wmctrl -ic <numeric_id>
-
To close the active window:
~$ wmctrl -c :ACTIVE:
-
To use the pid to get a list of windows, owned by a specific application (e.g. gedit):
~$ pidof gedit 22576 ~$ wmctrl -l -p | grep 22576 0x04600085 0 22576 jacob-System-Product-Name get.sh (~/Bureaublad) - gedit 0x0461aee4 0 22576 jacob-System-Product-Name verhaal (~/Bureaublad) - gedit 0x0461b0a1 0 22576 jacob-System-Product-Name *Niet-opgeslagen document 1 - gedit
then close the specific window
get.sh
by either:wmctrl -c get.sh
or:
wmctrl -ic 0x04600085
-
If you know only part of the window name, e.g. there is a window;
monkey eats banana.txt
, you know it hasbanana
in its name,-
first bring the window to front:
wmctrl -a banana
then decide if you want to close the window (as active window for example)
-
options are numerous, see also man wmctrl. man wmctrl