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.
Printable View
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.
On 2008-10-06, Kenny McCormack <gazelle@shell.xmission.com> wrote:[color=blue]
> 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.[/color]
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
[email]spamtrap42@verizon.net[/email]
(Yes, that is one of my email addresses.)
In article <slrngelr5v.6t5.rmriches@one.localnet>,
Robert Riches <spamtrap42@verizon.net> wrote:[color=blue]
>On 2008-10-06, Kenny McCormack <gazelle@shell.xmission.com> wrote:[color=green]
>> 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.[/color]
>
>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.[/color]
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).
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Kenny McCormack writes:
[...]
[color=blue]
> Yes, but only if given the full window name.[/color]
[color=blue]
> Suppose I have a window called:[/color]
[color=blue]
> Very long name, version x.y.z on 10/6/08[/color]
[color=blue]
> 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).[/color]
% 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
/\ [url]www.asciiribbon.org[/url] - against proprietary attachments
·-- ·- ···· ·--- ·- ···- ·- ·--·-· --· -- ·- ·· ·-·· ·-·-·- -·-· --- --
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
iEYEARECAAYFAkjrTtsACgkQHy+EEHYuXnSSfACfZAI8x9ejYwY/1bo2O1PGCQPK
va8An31Xbybh/6a01J1zAbxh+5pOdUHC
=TmA0
-----END PGP SIGNATURE-----
In article <874p3ok46f.fsf@chateau.d.lf>,
Ashish Shukla ठशॠष श ॠठॠल <wahjava@gmail.com> wrote:
....[color=blue][color=green]
>> 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).[/color]
>
>% xlsclients -a -l |awk '/^Window/ { if(gsub(":","", $2)) \
> printf("%s ", $2); } /^[[:space:]]*Name:/ { print($2); }'
>0x1000001 emacs
>0x1606daf urxvt
>0x1600009
>0x160c124 urxvt[/color]
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.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Kenny McCormack writes:
[...]
[color=blue]
> 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.[/color]
Back in the days, when X used to be monolithic, 'rpm -ql <xorg-package>
|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:
[url]http://xorg.freedesktop.org/releases/current/src/app/[/url]
Ashish
- --
() ascii ribbon campaign - against HTML e-mail
/\ [url]www.asciiribbon.org[/url] - against proprietary attachments
·-- ·- ···· ·--- ·- ···- ·- ·--·-· --· -- ·- ·· ·-·· ·-·-·- -·-· --- --
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
iEYEARECAAYFAkjralkACgkQHy+EEHYuXnTBLQCg70giEVrY/13Ca5+AN7v7QqjQ
z9YAnAry2i+oZVA4PXGjrq7CwtJo+b6y
=rdMf
-----END PGP SIGNATURE-----
In article <87ej2sik6h.fsf@chateau.d.lf>,
Ashish Shukla <wahjava@gmail.com> wrote:[color=blue]
>
>[...]
>[color=green]
>> 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.[/color][/color]
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?
[color=blue]
>Back in the days, when X used to be monolithic, 'rpm -ql <xorg-package>[/color]
[color=blue]
>|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:
>[/color]
Knowing the names isn't the hard part. Knowing what they do is...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Kenny McCormack writes:[color=blue]
> In article <87ej2sik6h.fsf@chateau.d.lf>,
> Ashish Shukla <wahjava@gmail.com> wrote:[/color]
[...]
[color=blue]
> 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?[/color]
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
[color=blue][color=green]
>> Back in the days, when X used to be monolithic, 'rpm -ql <xorg-package>[/color][/color]
[color=blue][color=green]
>> |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:
>>[/color][/color]
[color=blue]
> Knowing the names isn't the hard part. Knowing what they do is...[/color]
RTFM
Ashish
- --
() ascii ribbon campaign - against HTML e-mail
/\ [url]www.asciiribbon.org[/url] - against proprietary attachments
·-- ·- ···· ·--- ·- ···- ·- ·--·-· --· -- ·- ·· ·-·· ·-·-·- -·-· --- --
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
iEYEARECAAYFAkjrty8ACgkQHy+EEHYuXnTRcwCfSbkJ2udf7veIJQsfEaD9RdC1
WZkAn0GZVogaHW3ft97WJgDqpLHytoz2
=G4wE
-----END PGP SIGNATURE-----
On 2008-10-07, Kenny McCormack <gazelle@shell.xmission.com> wrote:[color=blue]
> In article <slrngelr5v.6t5.rmriches@one.localnet>,
> Robert Riches <spamtrap42@verizon.net> wrote:[color=green]
>>On 2008-10-06, Kenny McCormack <gazelle@shell.xmission.com> wrote:[color=darkred]
>>> 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.[/color]
>>
>>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.[/color]
>
> 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).[/color]
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
[email]spamtrap42@verizon.net[/email]
(Yes, that is one of my email addresses.)
In article <slrngeofkf.lf0.rmriches@one.localnet>,
Robert Riches <spamtrap42@verizon.net> wrote:
....[color=blue]
>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.[/color]
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!
[color=blue]
>Or, is your question asking how to do an approximate string
>match?[/color]
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).
On 2008-10-08, Kenny McCormack <gazelle@shell.xmission.com> wrote:[color=blue]
> In article <slrngeofkf.lf0.rmriches@one.localnet>,
> Robert Riches <spamtrap42@verizon.net> wrote:
> ...[color=green]
>>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.[/color]
>
> 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!
>[color=green]
>>Or, is your question asking how to do an approximate string
>>match?[/color]
>
> 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).[/color]
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
[email]spamtrap42@verizon.net[/email]
(Yes, that is one of my email addresses.)