How can I find the Firefox window from xwininfo?
My Perl isn't very good at all and I am having trouble determining why this awesome perl script keeps returning:
Error: No running window found Couldn't find window [Mozilla] in [xwininfo -tree -root]
I have setup these variables:
my $PROGNAME = $0;
$PROGNAME =~ s|.*/||;
my $GRAB = 'xwd -silent -nobdrs -id %id | convert -quality 85 - %out';
my $XINFO = 'xwininfo -tree -root';
my $BROWSER = 'firefox'; # Must match find_window() code - see usage()
In usage it says this:
- Requires "Mozilla" or "Opera" browser
(update find_window() code for other browsers)
The code concerned is this:
# I'm using mozilla..
sub find_window {
$BROWSER eq "opera" ?
opera_find_window(@_) :
mozilla_find_window(@_);
}
How would I get the above to reflect a firefox browser. In my shell, if I type mozilla nothing happens, if i type firefox - my browser opens, so I should be using this.
Here is the code in question which returns that error:
sub mozilla_find_window {
open(XINFO,"$XINFO|") || die("Couldn't run: [$XINFO]\n");
# Pick the first mozilla window. It's got the title in it, but
# we have no way of knowing if that matches the URL, so we'll
# hope this is the right one..
my ($spacing,$id,$title,$x,$y);
while(<XINFO>) {
# This could easily break and is very mozilla specific (works on firefox)
# Looks for [...("Mozilla" "navigator:browser") ..]
# I'v开发者_StackOverflowe had this reported: 0x80002f "TITLE - Mozilla": ("Gecko" "Mozilla-bin") 889x687+0+22 +136+44
last if (($spacing,$id,$title,$x,$y) = (/^(\s+)(0x[0-9a-f]+) "(.*)\s*-\s*Mozilla.*": \("Mozilla" "navigator:browser"\)\s*$GEOM_RE$/));
last if (($spacing,$id,$title,$x,$y) = (/^(\s+)(0x[0-9a-f]+) "(.*)\s*-\s*Mozilla.*": \("mozilla-bin" "Mozilla-bin"\)\s*$GEOM_RE$/));
# Mozilla Firefox 1.0.4
last if (($spacing,$id,$title,$x,$y) = (/^(\s+)(0x[0-9a-f]+) "(.*)\s*-\s*Mozilla Firefox.*": \("Gecko" "Firefox-bin"\)\s*$GEOM_RE$/));
# Debian Mozilla Firefox
last if (($spacing,$id,$title,$x,$y) = (/^(\s+)(0x[0-9a-f]+) "(.*)\s*-\s*Mozilla Firefox.*": \("firefox-bin" "Firefox-bin"\)\s*$GEOM_RE$/));
}
die("Couldn't find window [Mozilla] in [$XINFO]\n") unless $title && $x && $y;
Anybody know how I can fix this, what I am doing wrong? It is a problem that is to do with the location where by firefox is installed?
Thanks all
Update
0x140529c "Firefox": () 10x10+-100+-100 +-100+-100 0x14051b9 "Firefox": () 10x10+-100+-100 +-100+-100 0x14038c9 "Firefox": ("firefox" "Firefox") 1x1+-100+-100 +-100+-100 1 child: 0x14038ca (has no name): () 1x1+-1+-1 +-101+-101 0x14002bd "Firefox": () 1x1+0+0 +0+0 1 child: 0x14002be (has no name): () 1x1+-1+-1 +-1+-1 0x1400210 "Firefox": () 10x10+-100+-100 +-100+-100 0x14000ea "Firefox": ("firefox" "Firefox") 200x200+0+0 +0+0 1 child: 0x14000eb (has no name): () 1x1+-1+-1 +-1+-1 0x14000a6 "Firefox": ("firefox" "Firefox") 200x200+0+0 +0+0 2 children: 0x14000a9 (has no name): () 1x1+-1+-1 +-1+-1 1 child: 0x14000aa (has no name): () 1x1+2+2 +1+1 1 child: 0x14000ab (has no name): () 1x1+0+0 +1+1 4 children: 0x140519f (has no name): () 1x1+-1+-1 +0+0 0x140519e (has no name): () 1x1+-1+-1 +0+0 0x1400286 (has no name): () 1x1+-1+-1 +0+0 0x14000ad (has no name): () 1x1+-1+-1 +0+0 0x14000a7 (has no name): () 1x1+-1+-1 +-1+-1 0x140008d "Firefox": ("firefox" "Firefox") 200x200+0+0 +0+0
The above is obtained when I run this manually xwininfo -tree -root
You can see from the output of xwininfo
that your Firefox shows up in the X window list as "Firefox": ("firefox" "Firefox").
None of your regexes are currently looking for this combination. Add this code directly after the #Debian Mozilla Firefox
lines (or at least somewhere in that same while
block):
# my Firefox
last if (($spacing,$id,$title,$x,$y) = (/^(\s+)(0x[0-9a-f]+) "(Firefox)": \("firefox" "Firefox"\)\s*$GEOM_RE$/));
精彩评论