Raise all windows with a specific title

I'm trying to find a way to raise all the windows that have one, specific title.

For example, I have two windows named superconky (yes, you guessed it, I'm trying to get conky running in lubuntu).

I have a command I got from the LXDE forums: sh -c 'wmctrl -k on; wmctrl -a superconky;'

I use it to show the desktop, except conky. It works perfectly, but only if you have one conky. If you have two or more, you get left with one and all the others minimized.

So, what should I do to raise all the windows?

Thanks in advance.


Solution 1:

"So, what should I do to raise all the windows?"

Presumably you mean all the conky windows?

Since wmctrl is not doing what you want by specifying the window name, you should use the more exact method of speciying the window id.

To get the list of window ids one does

wmctrl -l

So assuming your windows have superconky in the title, to extract just the window ids from that list

windowid_list="`wmctrl -l | sed -ne 's|^\([^ ]*\).*superconky.*|\1|p'`"

Then process the list

if [ -n "${windowid_list}" ]
then
     for windowid in ${windowid_list}
     do
         wmctrl -i -a "${windowid}"
     done
fi

Take note that the "-i" flag to denote a numeric windowid must be specified before the action flag ("-a", "-R", or whatever) or nothing happens.

Also take note that "-a" raises and focuses the window and that only one window can be focused at a time.

Also, if the second superconky window is directly underneath the first one, when the second one is raised, it will obscure the first.