-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
hotdog-listMonitors.pl~freebsd
executable file
·59 lines (48 loc) · 1.38 KB
/
hotdog-listMonitors.pl~freebsd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env perl
$|=1;
use strict;
sub get_monitors
{
my @lines = `xrandr --verbose`;
chomp @lines;
my @results = ();
foreach my $line (@lines) {
if ($line =~ m/ connected /) {
$line =~ s/ connected / /;
$line =~ s/ primary / /;
my %elt = ();
# if ($line =~ m/^([^\s]+)\s+(\d+)x(\d+)\+(\d+)\+(\d+)\s([^\(]*)\(/) {
if ($line =~ m/^([^\s]+)\s+(\d+)x(\d+)\+(\d+)\+(\d+)\s+\([^\)]*\)\s+([a-z]+)/) {
$elt{'output'} = $1;
$elt{'width'} = $2;
$elt{'height'} = $3;
$elt{'x'} = $4;
$elt{'y'} = $5;
$elt{'rotate'} = $6;
if (not $elt{'rotate'}) {
$elt{'rotate'} = 'normal';
}
} elsif ($line =~ m/^([^\s]+)\s/) {
$elt{'output'} = $1;
}
push @results, \%elt;
}
}
@results = sort {
if ($a->{'x'} eq '') {
return 1;
}
if ($b->{'x'} eq '') {
return 1;
}
return $a->{'x'} <=> $b->{'x'};
} @results;
return @results;
}
my @results = get_monitors();
my @keys = ('output', 'width', 'height', 'x', 'y', 'rotate');
foreach my $elt (@results) {
my @vals = map { $_ . ':' . $elt->{$_} } @keys;
my $str = join ' ', @vals;
print "$str\n";
}