The combination of xlsw
and xdotool
does the trick.
xlsw
lists windows by their title and type, xdotool
does actions on them. In principle, xdotool
can also search for windows' names, but it missed what were popup windows.
In bash
:
xlsw | grep 'Firefox/Popup' | awk '{print $1}' | \
while read _windowID; do xdotool windowclose "${_windowID}"; done
Explanation:
xlsw
outputs a list of window-IDs together with additional information. Output looks like:
[...]
0x04800001 u-- Pale moon/pale moon Pale Moon
0x04800092 uio NA Pale Moon
0x04800093 u-o Pale moon/palemoon Pale Moon
0x04800099 u-o Pale moon/palemoon Pale Moon
0x04828D21 u-o Pale moon/Popup Pale Moon
0x0489C5D6 u-o Pale moon/Popup Pale Moon
0x03600001 ui- NA NA
0x04604E77 --o Claws-mail/claws-mail claws-mail
0x04604EAC --o Claws-mail/claws-mail claws-mail
0x04604F22 --o Claws-mail/claws-mail claws-mail
0x05C00001 uio NA NA
0x05E00001 u-- NA NA
0x05200007 ui- NA NA
0x05E00002 u-- Wine/explorer.exe
[...]
Then, with the grep
-command, the popup-windows of firefox
will be selected (in the example above they are all gone, already). awk
prints the first entry, which is the window-ID, and then xdotool windowclose
will close the windows (something like hitting the close button) without killing it's controlling application. (xdotool windowkill
would kill the application.)
xdotool
has also a build in search: xdotool search 'firefox' windowclose
would also close all windows with 'firefox' in their title, but I did not get it to work to differentiate the 'Popup'.
wmctrl -c firefox
doesn't work for you?wmctrl
. You can make this a full answer to my question.