Tool to match partial window name (get ID)?

This is a discussion on Tool to match partial window name (get ID)? within the Xwindows forums, part of the Tools category; Is there a shell tool (xwininfo, xprop, etc) way to get the X WindowID for a window based on a partial match? xwininfo can do it, but you have to ...

Go Back   Unix Linux Forum > Technologies & Tools > Tools > Xwindows

FixUnix.com - Unix Linux Forums

Unix Content Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 10-06-2008, 04:01 PM
Default Tool to match partial window name (get ID)?

Is there a shell tool (xwininfo, xprop, etc) way to get the X WindowID
for a window based on a partial match? xwininfo can do it, but you have
to pass it the entire name. Quite often, it is inconvenient and/or you
may not know it.

Reply With Quote
  #2  
Old 10-07-2008, 12:59 AM
Default Re: Tool to match partial window name (get ID)?

On 2008-10-06, Kenny McCormack wrote:
> Is there a shell tool (xwininfo, xprop, etc) way to get the X WindowID
> for a window based on a partial match? xwininfo can do it, but you have
> to pass it the entire name. Quite often, it is inconvenient and/or you
> may not know it.


I forget which, but either xwininfo or xprop will give you
the window ID in hex. I used that the other day for some
screen captures.

--
Robert Riches
spamtrap42@verizon.net
(Yes, that is one of my email addresses.)
Reply With Quote
  #3  
Old 10-07-2008, 02:19 AM
Default Re: Tool to match partial window name (get ID)?

In article ,
Robert Riches wrote:
>On 2008-10-06, Kenny McCormack wrote:
>> Is there a shell tool (xwininfo, xprop, etc) way to get the X WindowID
>> for a window based on a partial match? xwininfo can do it, but you have
>> to pass it the entire name. Quite often, it is inconvenient and/or you
>> may not know it.

>
>I forget which, but either xwininfo or xprop will give you
>the window ID in hex. I used that the other day for some
>screen captures.


Yes, but only if given the full window name.

Suppose I have a window called:

Very long name, version x.y.z on 10/6/08

I can use xwininfo to get the ID for that window, but only if I write
out the whole name. It should be clear why that is not feasible.
I'd like to be able to just say "Very long name" (initial part of the
title).

Reply With Quote
  #4  
Old 10-07-2008, 07:58 AM
Default Re: Tool to match partial window name (get ID)?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kenny McCormack writes:

[...]

> Yes, but only if given the full window name.


> Suppose I have a window called:


> Very long name, version x.y.z on 10/6/08


> I can use xwininfo to get the ID for that window, but only if I write
> out the whole name. It should be clear why that is not feasible.
> I'd like to be able to just say "Very long name" (initial part of the
> title).


% xlsclients -a -l |awk '/^Window/ { if(gsub(":","", $2)) \
printf("%s ", $2); } /^[[:space:]]*Name:/ { print($2); }'
0x1000001 emacs
0x1606daf urxvt
0x1600009
0x160c124 urxvt

Ashish
- --
() ascii ribbon campaign - against HTML e-mail
/\ www.asciiribbon.org - against proprietary attachments
·-- ·- ···· ·--- ·- ···- ·- ·--·-· --· -- ·- ·· ·-·· ·-·-·- -·-· --- --
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)

iEYEARECAAYFAkjrTtsACgkQHy+EEHYuXnSSfACfZAI8x9ejYw Y/1bo2O1PGCQPK
va8An31Xbybh/6a01J1zAbxh+5pOdUHC
=TmA0
-----END PGP SIGNATURE-----
Reply With Quote
  #5  
Old 10-07-2008, 08:28 AM
Default Re: Tool to match partial window name (get ID)?

In article <874p3ok46f.fsf@chateau.d.lf>,
Ashish Shukla ठशॠष श ॠठॠल wrote:
....
>> I can use xwininfo to get the ID for that window, but only if I write
>> out the whole name. It should be clear why that is not feasible.
>> I'd like to be able to just say "Very long name" (initial part of the
>> title).

>
>% xlsclients -a -l |awk '/^Window/ { if(gsub(":","", $2)) \
> printf("%s ", $2); } /^[[:space:]]*Name:/ { print($2); }'
>0x1000001 emacs
>0x1606daf urxvt
>0x1600009
>0x160c124 urxvt


Yes. xlsclients looks very useful. One to add to the list...

A bit of background: Even though I've been using Unix and X for decades
(literally), I've never, until very recently, had the need to do "UI
automation" in the Unix/X context. Hence, all these questions. It
seems there's no single unified approach and no good way to find the
names of all these little tools.

Reply With Quote
  #6  
Old 10-07-2008, 09:55 AM
Default Re: Tool to match partial window name (get ID)?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kenny McCormack writes:

[...]

> A bit of background: Even though I've been using Unix and X for decades
> (literally), I've never, until very recently, had the need to do "UI
> automation" in the Unix/X context. Hence, all these questions. It
> seems there's no single unified approach and no good way to find the
> names of all these little tools.


Back in the days, when X used to be monolithic, 'rpm -ql
|fgrep bin' seems to do the job. Anyways most of these tools have their
names starting with 'x'. Checking out following will also be helpful:

http://xorg.freedesktop.org/releases/current/src/app/

Ashish
- --
() ascii ribbon campaign - against HTML e-mail
/\ www.asciiribbon.org - against proprietary attachments
·-- ·- ···· ·--- ·- ···- ·- ·--·-· --· -- ·- ·· ·-·· ·-·-·- -·-· --- --
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)

iEYEARECAAYFAkjralkACgkQHy+EEHYuXnTBLQCg70giEVrY/13Ca5+AN7v7QqjQ
z9YAnAry2i+oZVA4PXGjrq7CwtJo+b6y
=rdMf
-----END PGP SIGNATURE-----
Reply With Quote
  #7  
Old 10-07-2008, 12:01 PM
Default Re: Tool to match partial window name (get ID)?

In article <87ej2sik6h.fsf@chateau.d.lf>,
Ashish Shukla wrote:
>
>[...]
>
>> A bit of background: Even though I've been using Unix and X for decades
>> (literally), I've never, until very recently, had the need to do "UI
>> automation" in the Unix/X context. Hence, all these questions. It
>> seems there's no single unified approach and no good way to find the
>> names of all these little tools.


Actually, I spoke too soon. xlsclients doesn't display information for
all open windows (and, of course, skips the one I am interested in).
Do you know why this is?

>Back in the days, when X used to be monolithic, 'rpm -ql


>|fgrep bin' seems to do the job. Anyways most of these tools have their
>names starting with 'x'. Checking out following will also be helpful:
>


Knowing the names isn't the hard part. Knowing what they do is...

Reply With Quote
  #8  
Old 10-07-2008, 03:23 PM
Default Re: Tool to match partial window name (get ID)?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kenny McCormack writes:
> In article <87ej2sik6h.fsf@chateau.d.lf>,
> Ashish Shukla wrote:


[...]

> Actually, I spoke too soon. xlsclients doesn't display information for
> all open windows (and, of course, skips the one I am interested in).
> Do you know why this is?


Hmm...? On my box it works fine ? No ideas, why it fails on your
box. May be it is only meant to show clients connected, not windows. Try
following command, may be that'll help:

% xwininfo -children -root

>> Back in the days, when X used to be monolithic, 'rpm -ql


>> |fgrep bin' seems to do the job. Anyways most of these tools have their
>> names starting with 'x'. Checking out following will also be helpful:
>>


> Knowing the names isn't the hard part. Knowing what they do is...


RTFM

Ashish
- --
() ascii ribbon campaign - against HTML e-mail
/\ www.asciiribbon.org - against proprietary attachments
·-- ·- ···· ·--- ·- ···- ·- ·--·-· --· -- ·- ·· ·-·· ·-·-·- -·-· --- --
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)

iEYEARECAAYFAkjrty8ACgkQHy+EEHYuXnTRcwCfSbkJ2udf7v eIJQsfEaD9RdC1
WZkAn0GZVogaHW3ft97WJgDqpLHytoz2
=G4wE
-----END PGP SIGNATURE-----
Reply With Quote
  #9  
Old 10-08-2008, 01:01 AM
Default Re: Tool to match partial window name (get ID)?

On 2008-10-07, Kenny McCormack wrote:
> In article ,
> Robert Riches wrote:
>>On 2008-10-06, Kenny McCormack wrote:
>>> Is there a shell tool (xwininfo, xprop, etc) way to get the X WindowID
>>> for a window based on a partial match? xwininfo can do it, but you have
>>> to pass it the entire name. Quite often, it is inconvenient and/or you
>>> may not know it.

>>
>>I forget which, but either xwininfo or xprop will give you
>>the window ID in hex. I used that the other day for some
>>screen captures.

>
> Yes, but only if given the full window name.
>
> Suppose I have a window called:
>
> Very long name, version x.y.z on 10/6/08
>
> I can use xwininfo to get the ID for that window, but only if I write
> out the whole name. It should be clear why that is not feasible.
> I'd like to be able to just say "Very long name" (initial part of the
> title).


Can you click on the window or not? If you can, one of the
two, xwininfo and xprop, will give you the ID in
hexadecimal.

Or, is your question asking how to do an approximate string
match?

--
Robert Riches
spamtrap42@verizon.net
(Yes, that is one of my email addresses.)
Reply With Quote
  #10  
Old 10-08-2008, 07:28 AM
Default Re: Tool to match partial window name (get ID)?

In article ,
Robert Riches wrote:
....
>Can you click on the window or not? If you can, one of the
>two, xwininfo and xprop, will give you the ID in
>hexadecimal.


Yes, I know that xwininfo allows you to select the window by clicking on
it - and that is what I am currently doing in my script. The point was
to try to avoid having to do that - that is, make the process not
require manual intervention. Note also that one problem with the "click
on the window to choose it" method is that the window in question has to
be visible. Sometimes, I find that the window I want is covered up,
and, of course, you only get one click!

>Or, is your question asking how to do an approximate string
>match?


Not really "approximate", but rather "initial part of".

Note, incidentally, that a year or so ago, I asked here about a way to
"raise" a window, and you contributed a C program that walks the window
tree and finds windows matching a name. I modified that program to
match window names on initial string and I still use it (it is called
"xraise"). That program *could* be a solution to the instant problem; the
only reason I'm not happy with that is that it doesn't seem to actually
"raise" the window anymore (see other thread).

Reply With Quote
  #11  
Old 10-09-2008, 12:03 AM
Default Re: Tool to match partial window name (get ID)?

On 2008-10-08, Kenny McCormack wrote:
> In article ,
> Robert Riches wrote:
> ...
>>Can you click on the window or not? If you can, one of the
>>two, xwininfo and xprop, will give you the ID in
>>hexadecimal.

>
> Yes, I know that xwininfo allows you to select the window by clicking on
> it - and that is what I am currently doing in my script. The point was
> to try to avoid having to do that - that is, make the process not
> require manual intervention. Note also that one problem with the "click
> on the window to choose it" method is that the window in question has to
> be visible. Sometimes, I find that the window I want is covered up,
> and, of course, you only get one click!
>
>>Or, is your question asking how to do an approximate string
>>match?

>
> Not really "approximate", but rather "initial part of".
>
> Note, incidentally, that a year or so ago, I asked here about a way to
> "raise" a window, and you contributed a C program that walks the window
> tree and finds windows matching a name. I modified that program to
> match window names on initial string and I still use it (it is called
> "xraise"). That program *could* be a solution to the instant problem; the
> only reason I'm not happy with that is that it doesn't seem to actually
> "raise" the window anymore (see other thread).


It sounds like there are two problems here:

A partial (initial) string match. That should be easy for
you to code once you nail down your requirements.

I think I saw that thread but didn't pay attention. I'm
sorry I can't afford the time to help with that issue.

--
Robert Riches
spamtrap42@verizon.net
(Yes, that is one of my email addresses.)
Reply With Quote
Reply

Thread Tools


All times are GMT -5. The time now is 12:42 AM.

In an effort to better serve ads to our visitors, cookies are used on Fixunix.com. For more information, check out our Privacy Policy.

Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Ad Management by RedTyger