Skip to content

Commit

Permalink
split unix screens computing into its own function
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Rousse authored and Guillaume Rousse committed Jan 10, 2012
1 parent e9cbeec commit 03c7d4c
Showing 1 changed file with 17 additions and 24 deletions.
41 changes: 17 additions & 24 deletions lib/FusionInventory/Agent/Task/Inventory/Input/Generic/Screen.pm
Expand Up @@ -151,35 +151,28 @@ sub _getScreensFromWindows {

}

sub _getScreensFromUnix {

my $raw_edid =
getFirstLine(command => 'monitor-get-edid-using-vbe') ||
getFirstLine(command => 'monitor-get-edid');

sub _getScreens {
my ($logger) = @_;

my @screens;

if ($OSNAME eq 'MSWin32') {

return _getScreensFromWindows($logger);

} else {
# Mandriva
my $raw_edid =
getFirstLine(command => 'monitor-get-edid-using-vbe') ||
getFirstLine(command => 'monitor-get-edid');

if (!$raw_edid) {
foreach (1..5) { # Sometime get-edid return an empty string...
$raw_edid = getFirstLine(command => 'get-edid');
last if $raw_edid && (length($raw_edid) == 128 || length($raw_edid) == 256);
}
if (!$raw_edid) {
foreach (1..5) { # Sometime get-edid return an empty string...
$raw_edid = getFirstLine(command => 'get-edid');
last if $raw_edid && (length($raw_edid) == 128 || length($raw_edid) == 256);
}
return unless length($raw_edid) == 128 || length($raw_edid) == 256;

push @screens, { edid => $raw_edid };
}
return unless length($raw_edid) == 128 || length($raw_edid) == 256;

return ( { edid => $raw_edid } );
}

sub _getScreens {
my ($logger) = @_;

return @screens;
return $OSNAME eq 'MSWin32' ?
_getScreensFromWindows($logger) : _getScreensFromUnix($logger);
}

1;

0 comments on commit 03c7d4c

Please sign in to comment.