How can I bring all windows of an application to the front?

Solution 1:

You can use wmctrl for this:

There is a shortcut for all windows, e.g. if you just want to undo going to the desktop:

wmctrl -k off

If you really need to bring up just a specific app, you can use a script, as follows, but it will bring up all windows on all workspaces. E.g. to bring up all gnome-terminals, you could do

pids=" $(pidof gnome-terminal) "
wmctrl -lp | while read id a pid b; do
  test "${pids/ $pid }" != "$pids" && wmctrl -i -a $id
done

Solution 2:

If you just need to find all the windows of an application (with a preview of the contents in each) then click the app's icon twice in the launcher bar. The first time you click it will make the most recent window of the app active and the second time it will give you a preview of all the app's windows. That isn't technically the same as "bringing them to the top" but might meet the actual need you have (to find all the open email windows for example).

Solution 3:

Building on @Lajos' excellent answer to work with any app:

function showall {
  pids=" $(pidof $1) "
  wmctrl -lp | while read id a pid b
  do test "${pids/ $pid }" != "$pids" && wmctrl -i -a $id; done
}

Then call it like this:

showall gnome-terminal
showall nautilus
showall chrome