From bd420a538e45ef90f51ee319e75e549f3266d0cc Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Fri, 17 Jun 2005 08:00:45 +0000 Subject: add option to output using MonitorsDB format --- monitor-parse-edid | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'monitor-parse-edid') diff --git a/monitor-parse-edid b/monitor-parse-edid index 53e7d50..e35516a 100755 --- a/monitor-parse-edid +++ b/monitor-parse-edid @@ -375,6 +375,26 @@ sub ratio_name { } } +sub to_MonitorsDB { + my ($edid) = @_; + + $edid->{monitor_range} && $edid->{EISA_ID} or return; + + my $detailed_timings = $edid->{detailed_timings} || []; + my @preferred_resolutions = map { + join('x', $_->{horizontal_active}, $_->{vertical_active}); + } grep { !$_->{bad_ratio} } @$detailed_timings; + + join('; ', + $edid->{monitor_name} =~ /(\S+)/ ? $1 : $edid->{EISA_ID} =~ /(...)/ && $1, + $edid->{monitor_name} ? $edid->{monitor_name} : $edid->{EISA_ID} =~ /...(.*)/ && $1, + $edid->{EISA_ID}, + sprintf("%u-%u", $edid->{monitor_range}{horizontal_min}, $edid->{monitor_range}{horizontal_max}), + sprintf("%u-%u", $edid->{monitor_range}{vertical_min}, $edid->{monitor_range}{vertical_max}), + @$detailed_timings == 1 ? @preferred_resolutions : (), + ); +} + sub print_edid { my ($edid, $verbose) = @_; @@ -423,6 +443,7 @@ use Getopt::Long; GetOptions( 'v' => \ (my $verbose), 'perl' => \ (my $raw_perl), + 'MonitorsDB' => \ (my $MonitorsDB), ) or usage(); my $F; @@ -449,6 +470,9 @@ if ($raw_perl) { my $s = Dumper($edid); $s =~ s/.*? = {/+{/; # remove variable name we don't want print $s; +} elsif ($MonitorsDB) { + my $s = to_MonitorsDB($edid); + print "$s\n" if $s; } else { print_edid($edid, $verbose); } -- cgit v1.2.1