Discussion:
FVWM: Command-line tool for listing windows?
Chris Siebenmann
2012-01-30 21:28:03 UTC
Permalink
Does anyone know if there exists a good command line tool for listing
either the window IDs or the window names of all windows of a specific
class (or better yet, set of classes)? Or is this something that's
better done with an fvwm module written in Perl with fvwm-perllib[*]?

Thanks in advance.

- cks
[*: it's pretty easy to write a module to do this, but I'd prefer to
have a command line tool that I can hook into other scripts; my
shell scripting is better than my Perl.]
Mag. Dr. Nikolaus Klepp
2012-01-30 21:35:51 UTC
Permalink
Post by Chris Siebenmann
Does anyone know if there exists a good command line tool for listing
either the window IDs or the window names of all windows of a specific
class (or better yet, set of classes)? Or is this something that's
better done with an fvwm module written in Perl with fvwm-perllib[*]?
Thanks in advance.
- cks
[*: it's pretty easy to write a module to do this, but I'd prefer to
have a command line tool that I can hook into other scripts; my
shell scripting is better than my Perl.]
You could look at
xwininfo -root -tree
--
Mag. Dr. Nikolaus Klepp
Einnehmerstraße 14
A-4810 Gmunden
Tel.: +43 650 82 11 724
email: ***@klepp.biz
Thomas Adam
2012-01-30 22:32:44 UTC
Permalink
 Does anyone know if there exists a good command line tool for listing
either the window IDs or the window names of all windows of a specific
class (or better yet, set of classes)? Or is this something that's
better done with an fvwm module written in Perl with fvwm-perllib[*]?
xwininfo
xprop

But why not get FVWM to do it? No need for a module, just a
conditional command.

All (SomeCondition, ClassName, OtherCondition) Echo "$[w.id]: $[w.class]"

-- Thomas Adam
Chris Siebenmann
2012-01-30 22:49:17 UTC
Permalink
| On 30 January 2012 21:28, Chris Siebenmann <***@cs.toronto.edu> wrote:
| > €Does anyone know if there exists a good command line tool for
| > listing either the window IDs or the window names of all windows
| > of a specific class (or better yet, set of classes)? Or is this
| > something that's better done with an fvwm module written in Perl
| > with fvwm-perllib[*]?
|
| xwininfo
| xprop
|
| But why not get FVWM to do it? No need for a module, just a
| conditional command.
|
| All (SomeCondition, ClassName, OtherCondition) Echo "$[w.id]: $[w.class]"

Is there a way to write the output of All to a pipe or the like?

At this point it might be useful to explain my overall motivation: I
want to put together something that lets me select xterm windows from
the keyboard based on their name, with name completion. My current plan
is to use dmenu for the window name completion (and a script around it
to then act on the window). But for this I need to feed the window names
into dmenu[*].

(A recent display reorganization has moved things so that even the best
position for my usual FvwmIconMan is a bit far from things.)

It's possible that there's a better way to achieve this overall goal,
but I think the time that I asked about the overall goal this was the
best way in the current fvwm.

- cks
[*: dealing with duplicated window names is my problem; the code doesn't
have to worry about it.]
Kathryn Andersen
2012-01-31 05:14:47 UTC
Permalink
| > €Does anyone know if there exists a good command line tool for
| > listing either the window IDs or the window names of all windows
| > of a specific class (or better yet, set of classes)? Or is this
| > something that's better done with an fvwm module written in Perl
| > with fvwm-perllib[*]?
|
| xwininfo
| xprop
At this point it might be useful to explain my overall motivation: I
want to put together something that lets me select xterm windows from
the keyboard based on their name, with name completion. My current plan
is to use dmenu for the window name completion (and a script around it
to then act on the window). But for this I need to feed the window names
into dmenu[*].
I think wmctrl might help. It doesn't come standard with X but you
should be able to install it as a separate package.

The command "wmctrl -l -x" will list all the windows managed by the
window manager, and include their WM_CLASS classes. You could then
grep on the required classes and get the window names.

A bit of playing around got me this command line:

wmctrl -l -x | grep -i rxvt | cut -b47-

(note that I'm using rxvt rather than xterm for my terminals)

K.A.
--
_--_|\ | Kathryn Andersen <http://www.katspace.org>
/ \ |
\_.--.*/ | <http://kerravonsen.dreamwidth.org/>
v | <http://kerravonsen.redbubble.com/>
------------| Melbourne -> Victoria -> Australia -> Southern Hemisphere
Maranatha! | -> Earth -> Sol -> Milky Way Galaxy -> Universe
Thomas Adam
2012-01-31 09:17:27 UTC
Permalink
Post by Kathryn Andersen
| > €Does anyone know if there exists a good command line tool for
| > listing either the window IDs or the window names of all windows
| > of a specific class (or better yet, set of classes)? Or is this
| > something that's better done with an fvwm module written in Perl
| > with fvwm-perllib[*]?
|
| xwininfo
| xprop
At this point it might be useful to explain my overall motivation: I
want to put together something that lets me select xterm windows from
the keyboard based on their name, with name completion. My current plan
is to use dmenu for the window name completion (and a script around it
to then act on the window). But for this I need to feed the window names
into dmenu[*].
I think wmctrl might help. It doesn't come standard with X but you
should be able to install it as a separate package.
What's wrong with using xlsclients, which *does* come as standard?

-- Thomas Adam
Thomas Adam
2012-01-31 09:27:57 UTC
Permalink
| > €Does anyone know if there exists a good command line tool for
| > listing either the window IDs or the window names of all windows
| > of a specific class (or better yet, set of classes)? Or is this
| > something that's better done with an fvwm module written in Perl
| > with fvwm-perllib[*]?
|
| xwininfo
| xprop
|
| But why not get FVWM to do it? No need for a module, just a
| conditional command.
|
| All (SomeCondition, ClassName, OtherCondition) Echo "$[w.id]: $[w.class]"
Is there a way to write the output of All to a pipe or the like?
Not before dumping it to a temporary file as in:

All (...) PipeRead `echo $[w.class] >> /some/file`

And then processing /some/file, but note that there's the potential for
race-conditions here.
At this point it might be useful to explain my overall motivation: I
want to put together something that lets me select xterm windows from
the keyboard based on their name, with name completion. My current plan
is to use dmenu for the window name completion (and a script around it
to then act on the window). But for this I need to feed the window names
into dmenu[*].
Yes, your other thread on this which you started is no different to this --
except that now you no longer have the requirement of unique entries. You
stated before that unique entries were permissible.
(A recent display reorganization has moved things so that even the best
position for my usual FvwmIconMan is a bit far from things.)
It's possible that there's a better way to achieve this overall goal,
but I think the time that I asked about the overall goal this was the
best way in the current fvwm.
So something like this:

All (SomeWindowClass, OtherConditions) PipeRead \
`echo "FvwmCommand 'WindowId $[w.id] Focus'" >> /tmp/foo`

I do not care one way how to hook dmenu in to this, but that's how I would
do it above. Getting dmenu to understand what's in /tmp/foo, including any
bells and whistles, is completely down to you.

-- Thomas Adam

Loading...