Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

"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.

share|improve this answer
    
Thank you! Worked like a charm! Just one little thing: for the ease of use, could this be converted into a one-liner? If yes, it would be absolutely perfect. –  Doctor Jellyface Jul 9 at 19:29
    
@DoctorJellyface to shorten this you can create your own function and add it to the ~/.bashrc file. –  TuKsn Jul 9 at 21:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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