-
Notifications
You must be signed in to change notification settings - Fork 125
/
Videos.pm
79 lines (61 loc) · 1.95 KB
/
Videos.pm
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package FusionInventory::Agent::Task::Inventory::Input::MacOS::Videos;
use strict;
use warnings;
use FusionInventory::Agent::Tools;
use FusionInventory::Agent::Tools::MacOS;
sub isEnabled {
return canRun('/usr/sbin/system_profiler');
}
sub doInventory {
my (%params) = @_;
my $inventory = $params{inventory};
my %displays = _getDisplays();
foreach my $monitor (@{$displays{MONITORS}}) {
$inventory->addEntry(
section => 'MONITORS',
entry => $monitor,
);
}
foreach my $video (@{$displays{VIDEOS}}) {
$inventory->addEntry(
section => 'VIDEOS',
entry => $video,
);
}
}
sub _getDisplays {
my $infos = getSystemProfilerInfos(@_);
my @monitors;
my @videos;
foreach my $videoName (keys %{$infos->{'Graphics/Displays'}}) {
my $videoCardInfo = $infos->{'Graphics/Displays'}->{$videoName};
foreach my $displayName (keys %{$videoCardInfo->{Displays}}) {
next if $displayName eq 'Display Connector';
next if $displayName eq 'Display';
my $displayInfo = $videoCardInfo->{Displays}->{$displayName};
my $resolution = $displayInfo->{Resolution};
if ($resolution) {
$resolution =~ s/\ //g;
$resolution =~ s/\@.*//g;
}
my $memory = $videoCardInfo->{'VRAM (Total)'};
$memory =~ s/\ .*//g if $memory;
push @videos, {
CHIPSET => $videoCardInfo->{'Chipset Model'},
MEMORY => $memory,
NAME => $videoName,
RESOLUTION => $resolution,
PCISLOT => $videoCardInfo->{Slot}
};
push @monitors, {
CAPTION => $displayName,
DESCRIPTION => $displayName,
}
}
}
return (
MONITORS => \@monitors,
VIDEOS => \@videos
);
}
1;