| 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__ | ||