line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id$ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# xorg::xwininfo Brik |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
package Metabrik::Xorg::Xwininfo; |
7
|
1
|
|
|
1
|
|
737
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
8
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use base qw(Metabrik::Shell::Command Metabrik::System::Package); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
759
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub brik_properties { |
13
|
|
|
|
|
|
|
return { |
14
|
0
|
|
|
0
|
1
|
|
revision => '$Revision$', |
15
|
|
|
|
|
|
|
tags => [ qw(unstable) ], |
16
|
|
|
|
|
|
|
author => 'GomoR ', |
17
|
|
|
|
|
|
|
license => 'http://opensource.org/licenses/BSD-3-Clause', |
18
|
|
|
|
|
|
|
attributes => { |
19
|
|
|
|
|
|
|
display => [ qw(display) ], |
20
|
|
|
|
|
|
|
}, |
21
|
|
|
|
|
|
|
attributes_default => { |
22
|
|
|
|
|
|
|
display => ':0.0', |
23
|
|
|
|
|
|
|
}, |
24
|
|
|
|
|
|
|
commands => { |
25
|
|
|
|
|
|
|
install => [ ], # Inherited |
26
|
|
|
|
|
|
|
list => [ qw(display|OPTIONAL) ], |
27
|
|
|
|
|
|
|
show => [ qw(display|OPTIONAL) ], |
28
|
|
|
|
|
|
|
}, |
29
|
|
|
|
|
|
|
require_binaries => { |
30
|
|
|
|
|
|
|
xwininfo => [ ], |
31
|
|
|
|
|
|
|
}, |
32
|
|
|
|
|
|
|
need_packages => { |
33
|
|
|
|
|
|
|
ubuntu => [ qw(x11-utils) ], |
34
|
|
|
|
|
|
|
debian => [ qw(x11-utils) ], |
35
|
|
|
|
|
|
|
kali => [ qw(x11-utils) ], |
36
|
|
|
|
|
|
|
}, |
37
|
|
|
|
|
|
|
}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub list { |
41
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
42
|
0
|
|
|
|
|
|
my ($display) = @_; |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
0
|
|
|
|
$display ||= $self->display; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $cmd = "xwininfo -root -tree -display $display"; |
47
|
0
|
0
|
|
|
|
|
my $lines = $self->capture($cmd) or return; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my @r = (); |
50
|
0
|
|
|
|
|
|
my $c = 0; |
51
|
0
|
|
|
|
|
|
for (@$lines) { |
52
|
|
|
|
|
|
|
# " Root window id: 0xd5 (the root window) \"i3\"", |
53
|
0
|
0
|
|
|
|
|
if (/Root window id/) { |
|
|
0
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my ($id) = $_ =~ m{Root window id:\s+(\S+)}; |
55
|
0
|
|
|
|
|
|
$r[$c]->{id} = $id; |
56
|
0
|
|
|
|
|
|
$r[$c]->{nid} = int(hex($id)); |
57
|
0
|
|
|
|
|
|
$r[$c]->{name} = 'root'; |
58
|
0
|
|
|
|
|
|
$r[$c]->{command} = ''; |
59
|
0
|
|
|
|
|
|
$r[$c]->{title} = ''; |
60
|
0
|
|
|
|
|
|
$r[$c]->{geometry} = ''; |
61
|
0
|
|
|
|
|
|
$r[$c]->{position} = ''; |
62
|
0
|
|
|
|
|
|
$c++; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
# " 0x14232ea \"Xfce Terminal\": (\"xfce4-terminal\" \"Xfce4-terminal\") 171x211+1083+388 +1083+388", |
65
|
|
|
|
|
|
|
elsif (/^\s+0x/) { |
66
|
0
|
|
|
|
|
|
my ($id, $name, $command, $geometry, $position) = $_ =~ |
67
|
|
|
|
|
|
|
m{^\s+(\S+)\s+([^:]+):\s+\(([^)]*)\)\s+(\S+)\s+(\S+)}; |
68
|
0
|
|
|
|
|
|
$name =~ s/(?:^"|"$)//g; |
69
|
0
|
|
|
|
|
|
my ($com, $title) = $command =~ m{^"([^"]*)"\s+"([^"]*)"$}; |
70
|
0
|
|
|
|
|
|
$r[$c]->{id} = $id; |
71
|
0
|
|
|
|
|
|
$r[$c]->{nid} = int(hex($id)); |
72
|
0
|
|
|
|
|
|
$r[$c]->{name} = $name; |
73
|
0
|
|
0
|
|
|
|
$r[$c]->{command} = $com || $command; |
74
|
0
|
|
0
|
|
|
|
$r[$c]->{title} = $title || ''; |
75
|
0
|
|
|
|
|
|
$r[$c]->{geometry} = $geometry; |
76
|
0
|
|
|
|
|
|
$r[$c]->{position} = $position; |
77
|
0
|
|
|
|
|
|
$c++; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
return \@r; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub show { |
85
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
86
|
0
|
|
|
|
|
|
my ($display) = @_; |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
0
|
|
|
|
$display ||= $self->display; |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
my $cmd = "xwininfo -root -tree -display $display"; |
91
|
0
|
|
|
|
|
|
return $self->execute($cmd); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
__END__ |