Skip to content

Commit

Permalink
Linux: load edid file directly from /sys
Browse files Browse the repository at this point in the history
get-edid doesn't work with HDMI screen. This solution uses
/sys directly if possible.
  • Loading branch information
Gonéri Le Bouder authored and guillomovitch committed May 15, 2012
1 parent 33c6596 commit 3accc43
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions lib/FusionInventory/Agent/Task/Inventory/Input/Generic/Screen.pm
Expand Up @@ -7,13 +7,15 @@ use English qw(-no_match_vars);
use MIME::Base64;
use UNIVERSAL::require;

use File::Find;
use FusionInventory::Agent::Tools;
use FusionInventory::Agent::Tools::Screen;

sub isEnabled {

return
$OSNAME eq 'MSWin32' ||
-d '/sys' ||
canRun('monitor-get-edid-using-vbe') ||
canRun('monitor-get-edid') ||
canRun('get-edid');
Expand Down Expand Up @@ -42,8 +44,8 @@ sub doInventory {
}
$screen->{BASE64} = encode_base64($screen->{edid});

delete $screen->{edid};
}
delete $screen->{edid};

$inventory->addEntry(
section => 'MONITORS',
Expand Down Expand Up @@ -113,18 +115,39 @@ sub _getScreensFromWindows {

sub _getScreensFromUnix {

my @screens;

my $wanted = sub {
return unless $File::Find::name =~ m{(/edid)$};
open my $t, "<$File::Find::name";
my $edid = <$t>;
close $t;

push @screens, { edid => $edid } if $edid;
};

if (-d '/sys') {
File::Find::find($wanted, '/sys');
}

return @screens if @screens;

my $edid =
getFirstLine(command => 'monitor-get-edid-using-vbe') ||
getFirstLine(command => 'monitor-get-edid');
push @screens, { edid => $edid };

if (!$edid) {
foreach (1..5) { # Sometime get-edid return an empty string...
$edid = getFirstLine(command => 'get-edid');
last if $edid;
return @screens if @screens;

foreach (1..5) { # Sometime get-edid return an empty string...
$edid = getFirstLine(command => 'get-edid');
if ($edid) {
push @screens, { edid => $edid };
last;
}
}

return ( { edid => $edid } );
return @screens;
}

sub _getScreens {
Expand Down

0 comments on commit 3accc43

Please sign in to comment.