Xorg/Xlsclients.pm

filter: Statementstmt 100% 9 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 12 / 12 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Xorg/Screenshot.pm ↑ Summary Xorg/Xrandr.pm »
1 #
2 # $Id$
3 #
4 # xorg::xlsclients Brik
5 #
6 package Metabrik::Xorg::Xlsclients;
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use base qw(Metabrik::Shell::Command Metabrik::System::Package);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub brik_properties {
13 return {
14 revision => '$Revision$',
15 tags => [ qw(unstable) ],
16 author => 'GomoR <GomoR[at]metabrik.org>',
17 license => 'http://opensource.org/licenses/BSD-3-Clause',
18 commands => {
19 install => [ ], # Inherited
20 list => [ ],
21 show => [ ],
22 },
23 require_binaries => {
24 xlsclients => [ ],
25 },
26 need_packages => {
27 ubuntu => [ qw(x11-utils) ],
28 debian => [ qw(x11-utils) ],
29 kali => [ qw(x11-utils) ],
30 },
31 };
32 }
33  
34 sub list {
35 my $self = shift;
36  
37 my $cmd = 'xlsclients -la';
38 my $lines = $self->capture($cmd) or return;
39  
40 my @r = ();
41 my $c = -1;
42 my $id = '0x0';
43 for (@$lines) {
44 if (/^Window/) {
45 ($id) = $_ =~ m{Window\s+(0x\S+):};
46 $c++;
47 $r[$c]->{id} = $id;
48 $r[$c]->{nid} = int(hex($id));
49 }
50 else {
51 my ($name, $value) = $_ =~ m{^\s+([^:]+):\s+(.*)$};
52 $name =~ s/(?:\s+|\/)/_/g;
53 $r[$c]->{lc($name)} = $value;
54 }
55 }
56  
57 return \@r;
58 }
59  
60 sub show {
61 my $self = shift;
62  
63 my $cmd = 'xlsclients -la';
64 return $self->execute($cmd);
65 }
66  
67 1;
68  
69 __END__
« Xorg/Screenshot.pm ↑ Summary Xorg/Xrandr.pm »