I need to know that how can I find the list of open "windows" and then close some of them. Note that any window is required meaning that some of the window (like Plot) may be opened during a simulation with a software. I also want to detect them. Imagine that I use a mathematic software and it plot a graph in a new window.


Use the wmctrl program.

an example (done with KDE as DE)

#list open windows
wmctrl -l
0x01e001a6 -1 HOSTNAME plasma-desktop
0x01e007c1 -1 HOSTNAME plasma-desktop
0x01e00194 -1 HOSTNAME plasma-desktop
0x01e0019d -1 HOSTNAME plasma-desktop
0x03c00064  0 HOSTNAME Inbox - Mozilla Thunderbird
0x0240001a  0 HOSTNAME pam.d : bash – Konsole
0x04e00009  0 HOSTNAME 
0x03e0006e  0 HOSTNAME shell - check the list of Open window - Unix & Linux Stack Exchange - Mozilla Firefox
0x03e6efe3  0 HOSTNAME Mozilla Firefox

#now close the empty firefox session: (-c for close, -i for using the hexnumber of the first column as identifier)
wmctrl -ic 0x03e6efe3

You can also use this program for changing window geometries, selecting windows, moving windows, change window titles etc. Check man wmctrl for viewing the possibilities.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.