From 788a98ff032ae23f93d87eb1dff1c9e2f66e2fd9 Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Tue, 28 Aug 2018 22:35:30 -0400 Subject: New upstream version 3.0.22-1 --- inxi | 1541 +++++++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 915 insertions(+), 626 deletions(-) (limited to 'inxi') diff --git a/inxi b/inxi index f06943c..299c705 100755 --- a/inxi +++ b/inxi @@ -31,8 +31,8 @@ use POSIX qw(uname strftime ttyname); ## INXI INFO ## my $self_name='inxi'; -my $self_version='3.0.20'; -my $self_date='2018-07-30'; +my $self_version='3.0.22'; +my $self_date='2018-08-28'; my $self_patch='00'; ## END INXI INFO ## @@ -65,13 +65,14 @@ my (@dm_boot_disk,@dm_boot_optical,@glabel,@gpart,@hardware_raid,@labels, my @test = (0,0,0,0,0); ## Booleans -my ($b_admin,$b_arm,$b_console_irc,$b_debug_gz,$b_debug_timers, +my ($b_admin,$b_arm,$b_bb_ps,$b_console_irc,$b_debug_gz,$b_debug_timers, $b_display,$b_dmesg_boot_check, $b_dmi,$b_dmidecode_force,$b_fake_bsd,$b_fake_dboot,$b_fake_pciconf, $b_fake_sysctl,$b_fake_usbdevs,$b_force_display,$b_gpudata,$b_irc, $b_log,$b_log_colors,$b_log_full,$b_man,$b_mem,$b_mips,$b_pci,$b_pci_tool, -$b_proc_debug,$b_ps_gui,$b_root,$b_running_in_display,$b_slot_tool, -$b_soc_audio,$b_soc_gfx,$b_soc_net,$b_sudo,$b_sysctl,$b_usb_check,$b_wmctrl); +$b_ppc,$b_proc_debug,$b_ps_gui,$b_root,$b_running_in_display,$b_slot_tool, +$b_soc_audio,$b_soc_gfx,$b_soc_net,$b_sparc,$b_sudo,$b_sys_debug,$b_sysctl, +$b_usb,$b_usb_check,$b_usb_sys,$b_usb_tool,$b_wmctrl); ## Disk checks my ($b_dm_boot_disk,$b_dm_boot_optical,$b_glabel,$b_hardware_raid, $b_label_uuid,$b_lsblk,$b_partitions,$b_raid); @@ -80,7 +81,7 @@ my ($b_sysctl_disk,$b_update,$b_weather) = (1,1,1); ## System my ($bsd_type,$language,$os) = ('','',''); my ($bits_sys,$cpu_arch); -my ($cpu_sleep,$dl_timeout,$limit,$ps_count,$usb_level) = (0.35,4,10,5,0); +my ($cpu_sleep,$dl_timeout,$limit,$ps_cols,$ps_count) = (0.35,4,10,0,5); my $sensors_cpu_nu = 0; my $weather_unit='mi'; @@ -268,7 +269,7 @@ sub check_tools { %commands = ('sensors' => 'linux',); } # note: lsusb ships in FreeBSD ports sysutils/usbutils - if ( $usb_level ){ + if ( $b_usb ){ %hash = ('lsusb' => 'all',); %commands = (%commands,%hash); %hash = ('usbdevs' => 'bsd',); @@ -414,6 +415,8 @@ sub set_os { $cpu_arch = lc($uname[-1]); if ($cpu_arch =~ /arm|aarch/){$b_arm = 1} elsif ($cpu_arch =~ /mips/) {$b_mips = 1} + elsif ($cpu_arch =~ /power|ppc/) {$b_ppc = 1} + elsif ($cpu_arch =~ /sparc/) {$b_sparc = 1} # aarch32 mips32 intel/amd handled in cpu if ($cpu_arch =~ /(armv[1-7]|32|sparc_v9)/){ $bits_sys = 32; @@ -1065,6 +1068,7 @@ sub get_config_item { elsif ($key eq 'PS_COUNT') {$ps_count = $val if is_int($val) } elsif ($key eq 'SENSORS_CPU_NO') {$sensors_cpu_nu = $val if is_int($val)} elsif ($key eq 'SHOW_HOST' || $key eq 'B_SHOW_HOST') { $show{'host'} = $val if is_int($val)} + elsif ($key eq 'USB_SYS') {$b_usb_sys = $val if is_int($val)} elsif ($key eq 'WEATHER_UNIT') { $val = lc($val) if $val; if ($val && $val =~ /^(c|f|cf|fc|i|m|im|mi)$/){ @@ -1311,7 +1315,8 @@ sub run_debugger { if (!$b_debug){ if ( -d '/sys' && main::count_dir_files('/sys') ){ build_tree('sys'); - sys_traverse_data(); + # kernel crash, not sure what creates it, for ppc, as root + sys_traverse_data() if (!$b_root || !$b_ppc || $b_sys_debug) ; } else { print "Skipping /sys data collection. /sys not present, or empty.\n"; @@ -1356,6 +1361,8 @@ sub create_debug_directory { $bsd_string = "-BSD-$bsd_type" if $bsd_type; if ($b_arm ){$alt_string = '-ARM'} elsif ($b_mips) {$alt_string = '-MIPS'} + elsif ($b_ppc) {$alt_string = '-PPC'} + elsif ($b_sparc) {$alt_string = '-SPARC'} $debug_dir = "$self_name$alt_string$bsd_string-$host-$today$root_string-$self_version"; $debug_gz = "$debug_dir.tar.gz"; $data_dir = "$user_data_dir/$debug_dir"; @@ -1704,6 +1711,7 @@ sub system_data { ['lspci','-mmnn'], ['lspci','-v'], ['lsusb',''], + ['lsusb','-t'], ['lsusb','-v'], ['ps','aux'], ['ps','-e'], @@ -2022,7 +2030,7 @@ sub wanted { # not use it. Also do not need . files or __ starting files # print $File::Find::name . "\n"; # block maybe: cfgroup\/ - return if $File::Find::name =~ /\/(\.[a-z]|kernel\/|parameters\/|debug\/)/; + return if $File::Find::name =~ /\/(\.[a-z]|kernel\/|trace\/|parameters\/|debug\/)/; # comment this one out if you experience hangs or if # we discover syntax of foreign language characters # Must be ascii like. This is questionable and might require further @@ -2751,7 +2759,7 @@ sub item_data { 'rpm' => 'util-linux-ng', }), 'lsusb' => ({ - 'info' => '-A usb audio; -N usb networking; --usb', + 'info' => '-A usb audio; -N usb networking; --usb (optional)', 'info-bsd' => '-A; -N; --usb. Alternate to usbdevs', 'apt' => 'usbutils', 'pacman' => 'usbutils', @@ -3016,6 +3024,25 @@ sub cleanup { } } +# args: $1, $2, version numbers to compare by turning them to strings +# note that the structure of the two numbers is expected to be fairly +# similar, otherwise it may not work perfectly. +sub compare_versions { + my ($one,$two) = @_; + if ($one && !$two){return $one;} + elsif ($two && !$one){return $two;} + elsif (!$one && !$two){return} + my ($pad1,$pad2) = ('',''); + my (@temp1) = split /[\.\-_]/, $one; + my (@temp2) = split /[\.\-_]/, $two; + @temp1 = map {$_ = sprintf("%04s", $_);$_ } @temp1; + @temp2 = map {$_ = sprintf("%04s", $_);$_ } @temp2; + $pad1 = join '', @temp1; + $pad2 = join '', @temp2; + # print "p1:$pad1 p2:$pad2\n"; + if ($pad1 ge $pad2){return $one} + elsif ($pad2 gt $pad1){return $two} +} # returns count of files in directory, if 0, dir is empty sub count_dir_files { return unless -d $_[0]; @@ -3067,12 +3094,12 @@ sub globber { } ## NOTE: for perl pre 5.012 length(undef) returns warning -# receives string, returns boolean 0/1 if integer +# receives string, returns boolean 1 if integer sub is_int { return 1 if (defined $_[0] && length($_[0]) && length($_[0]) == ($_[0] =~ tr/0123456789//)); } -# receives string, returns boolean 0/1 if numeric. tr/// is 4x faster than regex +# receives string, returns boolean 1 if numeric. tr/// is 4x faster than regex sub is_numeric { return 1 if ( defined $_[0] && ( $_[0] =~ tr/0123456789//) >= 1 && length($_[0]) == ($_[0] =~ tr/0123456789.//) && ($_[0] =~ tr/.//) <= 1); @@ -3098,6 +3125,30 @@ sub joiner { return $string; } +# returns array of: 0: program print name 1: program version +# args: 1: program values id 2: program version string +# 3: extra level. Note that StartClient runs BEFORE -x levels are set! +# Only use this function when you only need the name/version data returned +# Important: all tests that use this must explicitly have program_values +# set for each item tested for!! +sub program_data { + eval $start if $b_log; + my ($values_id,$version_id,$level) = @_; + my (@data,$path,@program_data); + $level = 0 if ! $level; + #print "val_id: $values_id ver_id:$version_id lev:$level ex:$extra\n"; + $version_id = $values_id if ! $version_id; + @data = main::program_values($values_id); + $program_data[0] = $data[3]; + # programs that have no version method return 0 0 for index 1 and 2 + if ( $extra >= $level && $data[1] && $data[2]){ + $program_data[1] = main::program_version($version_id,$data[0],$data[1],$data[2],$data[5],$data[6]); + } + $program_data[1] = '' if ! defined $program_data[1]; + eval $end if $b_log; + return @program_data; +} + # returns array of: # 0 - match string; 1 - search number; 2 - version string [alt: file]; # 3 - Print name; 4 - console 0/1; @@ -3106,7 +3157,7 @@ sub joiner { # arg: 1 - program lower case name sub program_values { my ($app) = @_; - my (@client_data); + my (@program_data); # note: setting index 1 and 2 to 0 will trip flags to not do version my %data = ( ## Clients @@ -3135,43 +3186,60 @@ sub program_values { '9wm' => ['^9wm',3,'-version','9wm',0,1,0], 'afterstep' => ['^afterstep',3,'--version','AfterStep',0,1,0], 'amiwm' => ['^amiwm',0,'0','AmiWM',0,1,0], + 'asc' => ['^asc',0,'0','asc',0,1,0], 'awesome' => ['^awesome',2,'--version','Awesome',0,1,0], 'blackbox' => ['^Blackbox',2,'--version','Blackbox',0,1,0], 'bspwm' => ['^\S',1,'-v','bspwm',0,1,0], 'budgie' => ['^budgie-desktop',2,'--version','Budgie',0,1,0], + 'budgie-wm' => ['^budgie',0,'0','budgie-wm',0,1,0], 'cinnamon' => ['^cinnamon',2,'--version','Cinnamon',0,1,0], 'compiz' => ['^compiz',2,'--version','Compiz',0,1,0], + 'compton' => ['^\d',1,'--version','Compton',0,1,0], + 'dcompmgr' => ['^dcompmgr',0,'0','dcompmgr',0,1,0], 'deepin' => ['^Version',2,'file','Deepin',0,'=','/etc/deepin-version'], 'deepin-metacity' => ['^metacity',2,'--version','Deepin-Metacity',0,1,0], 'deepin-mutter' => ['^mutter',2,'--version','Deepin-Mutter',0,1,0], 'deepin-wm' => ['^gala',0,'0','DeepinWM',0,1,0], + 'dwc' => ['^dwc',0,'0','dwc',0,1,0], 'dwm' => ['^dwm',1,'-v','dwm',0,1,1], - 'fluxbox' => ['^fluxbox',2,'--version','Fluxbox',0,1,0], + # only listed here for compositor values, version data comes from xprop + 'enlightenment' => ['^enlightenment',0,'0','enlightenment',0,1,0], + 'fireplace' => ['^fireplace',0,'0','fireplace',0,1,0], + 'fluxbox' => ['^fluxbox',2,'-v','Fluxbox',0,1,0], 'flwm' => ['^flwm',0,'0','FLWM',0,0,1], 'fvwm' => ['^fvwm',2,'--version','FVWM',0,0,1], 'fvwm2' => ['^fvwm',2,'--version','FVWM2',0,0,1], # command: fvwm 'fvwm-crystal' => ['^fvwm',2,'--version','FVWM-Crystal',0,0,0], - 'gala' => ['^gala',2,'--version','gala',0,1,0], # super slow result + 'gala' => ['^gala',0,'0','gala',0,1,0], # super slow result, but 2, '--version' works? 'gnome-about' => ['gnome',3,'--version','Gnome',0,1,0], 'gnome-shell' => ['gnome',3,'--version','Gnome',0,1,0], - # with path, returns: /sbin/herbstluftwm [version] + 'grefson' => ['^grefson',0,'0','grefson',0,1,0], + # note, herbstluftwm when launched with full path returns full path in version string 'herbstluftwm' => ['herbstluftwm',2,'--version','herbstluftwm',0,1,0], 'jwm' => ['^jwm',2,'--version','JWM',0,1,0], # i3 version 4.13 (2016-11-08) © 2009 Michael Stapelberg and contributors 'i3' => ['^i3',3,'--version','i3',0,1,0], 'icewm' => ['^icewm',2,'--version','IceWM',0,1,0], + 'ion' => ['^ion',0,'0','Ion',0,1,0], 'kded' => ['^KDE Development Platform:',4,'--version','KDE',0,1,0], 'kded1' => ['^KDE Development Platform:',4,'--version','KDE',0,1,0], 'kded2' => ['^KDE Development Platform:',4,'--version','KDE',0,1,0], 'kded3' => ['^KDE Development Platform:',4,'--version','KDE',0,1,0], 'kded4' => ['^KDE Development Platform:',4,'--version','KDE',0,1,0], + 'ksmcon' => ['^ksmcon',0,'0','ksmcon',0,1,0], + 'kwin' => ['^kwin',0,'0','kwin',0,1,0], + 'kwin_wayland' => ['^kwin_wayland',0,'0','kwin_wayland',0,1,0], + 'kwin_x11' => ['^kwin_x11',0,'0','kwin_x11',0,1,0], + 'liri' => ['^liri',0,'0','liri',0,1,0], 'lumina' => ['^\S',1,'--version','Lumina',0,1,1], + 'lwm' => ['^lwm',0,'0','lwm',0,1,0], 'lxde' => ['^lxpanel',2,'--version','LXDE',0,1,0], # command: lxqt-panel 'lxqt' => ['^lxqt-panel',2,'--version','LXQt',0,1,0], 'lxqt-variant' => ['^lxqt-panel',0,'0','LXQt-Variant',0,1,0], 'lxsession' => ['^lxsession',0,'0','lxsession',0,1,0], + 'manokwari' => ['^manokwari',0,'0','Manokwari',0,1,0], 'marco' => ['^marco',2,'--version','marco',0,1,0], 'matchbox' => ['^matchbox',0,'0','Matchbox',0,1,0], 'matchbox-window-manager' => ['^matchbox',2,'--help','Matchbox',0,0,0], @@ -3179,27 +3247,50 @@ sub program_values { # note, mate-session when launched with full path returns full path in version string 'mate-session' => ['mate-session',-1,'--version','MATE',0,1,0], 'metacity' => ['^metacity',2,'--version','Metacity',0,1,0], + 'metisse' => ['^metisse',0,'0','metisse',0,1,0], + 'mir' => ['^mir',0,'0','mir',0,1,0], + 'motorcar' => ['^motorcar',0,'0','motorcar',0,1,0], 'muffin' => ['^muffin',2,'--version','muffin',0,1,0], + 'moblin' => ['^moblin',0,'0','moblin',0,1,0], + 'mutter' => ['^mutter',2,'--version','mutter',0,1,0], 'mwm' => ['^mwm',0,'0','mwm',0,1,0], + 'nawm' => ['^nawm',0,'0','nawm',0,1,0], 'notion' => ['^.',1,'--version','notion',0,1,0], 'openbox' => ['^openbox',2,'--version','Openbox',0,1,0], + 'orbital' => ['^orbital',0,'0','orbital',0,1,0], 'pantheon' => ['^pantheon',0,'0','Pantheon',0,1,0], + 'papyros' => ['^papyros',0,'0','papyros',0,1,0], 'pekwm' => ['^pekwm',3,'--version','PekWM',0,1,0], + 'perceptia' => ['^perceptia',0,'0','perceptia',0,1,0], 'plasmashell' => ['^plasmashell',2,'--version','KDE Plasma',0,1,0], 'qtdiag' => ['^qt',2,'--version','Qt',0,1,0], + 'qtile' => ['^qtile',0,'0','Qtile',0,0,1], 'razor' => ['^razor',0,'0','Razor-Qt',0,1,0], 'ratpoison' => ['^ratpoison',2,'--version','Ratpoison',0,1,0], + 'rustland' => ['^rustland',0,'0','rustland',0,1,0], 'sawfish' => ['^sawfish',3,'--version','Sawfish',0,1,0], 'scrotwm' => ['^scrotwm.*welcome.*',5,'-v','Scrotwm',0,1,1], + 'sommelier' => ['^sommelier',0,'0','sommelier',0,1,0], 'spectrwm' => ['^spectrwm.*welcome.*wm',5,'-v','Spectrwm',0,1,1], + 'sway' => ['^sway',0,'0','sway',0,1,0], + 'swc' => ['^swc',0,'0','swc',0,1,0], + 'tvtwm' => ['^tvtwm',0,'0','tvtwm',0,1,0], 'twin' => ['^Twin:',2,'--version','Twin',0,0,0], 'twm' => ['^twm',0,'0','twm',0,1,0], + 'unagi' => ['^unagi',0,'0','unagi',0,1,0], 'unity' => ['^unity',2,'--version','Unity',0,1,0], + 'wavy' => ['^wavy',0,'0','wavy',0,1,0], + 'way-cooler' => ['^way',0,'0','way-cooler',0,1,0], + 'wayhouse' => ['^wayhouse',0,'0','wayhouse',0,1,0], + 'westford' => ['^westford',0,'0','westford',0,1,0], + 'weston' => ['^weston',0,'0','weston',0,1,0], 'windowlab' => ['^windowlab',2,'-about','WindowLab',0,1,0], 'wm2' => ['^wm2',0,'0','wm2',0,1,0], 'wmaker' => ['^Window[[:space:]]*Maker',-1,'--version','WindowMaker',0,1,0], 'wmii' => ['^wmii',0,'0','wmii',0,1,0], # note: in debian, wmii is wmii3 'wmii2' => ['^wmii2',1,'--version','wmii2',0,1,0], + 'wmx' => ['^wmx',0,'0','wmx',0,1,0], + 'xcompmgr' => ['^xcompmgr',0,'0','xcompmgr',0,1,0], 'xfce4-panel' => ['^xfce4-panel',2,'--version','Xfce',0,1,0], 'xfce5-panel' => ['^xfce5-panel',2,'--version','Xfce',0,1,0], 'xfdesktop' => ['xfdesktop[[:space:]]version',5,'--version','Xfce',0,1,0], @@ -3207,10 +3298,21 @@ sub program_values { 'xfdesktop-toolkit' => ['Built[[:space:]]with[[:space:]]GTK',4,'--version','Gtk',0,1,0], 'xmonad' => ['^xmonad',2,'--version','XMonad',0,1,0], ## display managers (dm) - 'gdm' => ['^gdm',2,'--version','gdm',0,1,0], - 'gdm3' => ['^gdm',2,'--version','gdm3',0,1,0], - 'lightdm' => ['^lightdm',2,'--version','lightdm',0,1,1], - 'slim' => ['slim version',3,'-v','slim',0,1,0], + 'entrance' => ['^entrance',0,'0','Entrance',0,1,0], + 'gdm' => ['^gdm',2,'--version','GDM',0,1,0], + 'gdm3' => ['^gdm',2,'--version','GDM3',0,1,0], + 'kdm' => ['^kdm',0,'0','KDM',0,1,0], + 'ldm' => ['^ldm',0,'0','LDM',0,1,0], + 'lightdm' => ['^lightdm',2,'--version','LightDM',0,1,1], + 'lxdm' => ['^lxdm',0,'0','LXDM',0,1,0], + 'mdm' => ['^mdm',0,'0','MDM',0,1,0], + 'nodm' => ['^nodm',0,'0','nodm',0,1,0], + 'pcdm' => ['^pcdm',0,'0','PCDM',0,1,0], + 'sddm' => ['^sddm',0,'0','SDDM',0,1,0], + 'slim' => ['slim version',3,'-v','SLiM',0,1,0], + 'wdm' => ['^wdm',0,'0','WINGs DM',0,1,0], + 'xdm' => ['^xdm',0,'0','XDM',0,1,0], + 'xenodm' => ['^xenodm',0,'0','xenodm',0,1,0], ## Shells 'bash' => ['^GNU[[:space:]]bash,[[:space:]]version',4,'--version','Bash',1,0,0], 'csh' => ['^tcsh',2,'--version','csh',1,0,0], @@ -3232,11 +3334,11 @@ sub program_values { ); if ( defined $data{$app} ){ my $ref = $data{$app}; - @client_data = @$ref; + @program_data = @$ref; } - #my $debug = main::Dumper \@client_data; - main::log_data('dump',"Client Data",\@client_data) if $b_log; - return @client_data; + #my $debug = main::Dumper \@program_data; + main::log_data('dump',"Program Data",\@program_data) if $b_log; + return @program_data; } # args: 1 - desktop/app command for --version; 2 - search string; @@ -3385,7 +3487,6 @@ sub uniq { grep !$seen{$_}++, @_; } - # arg: 1 file full path to write to; 2 - arrayof data to write. # note: turning off strict refs so we can pass it a scalar or an array reference. sub writer { @@ -4032,6 +4133,8 @@ sub get_options{ $b_irc = 1; }, 'man' => sub { $b_use_man = 1; }, + 'mips' => sub { + $b_mips = 1 }, 'output:s' => sub { my ($opt,$arg) = @_; if ($arg =~ /^(json|screen|xml)$/){ @@ -4064,10 +4167,16 @@ sub get_options{ else { error_handler('bad-arg', $opt, $arg); }}, + 'ppc' => sub { + $b_ppc = 1 }, 'proc' => sub { $b_proc_debug = 1; }, 'recommends' => sub { $b_recommends = 1; }, + 'sparc' => sub { + $b_sparc = 1; }, + 'sys' => sub { + $b_sys_debug = 1; }, 'U|update:s' => sub { # 1,2,3 OR http://myserver/path/inxi my ($opt,$arg) = @_; $b_downloader = 1; @@ -4106,6 +4215,10 @@ sub get_options{ else { error_handler('distro-block', $opt); } }, + 'usb-sys' => sub { + $b_usb_sys = 1 }, + 'usb-tool' => sub { + $b_usb_tool = 1 }, 'V|version' => sub { $b_version = 1 }, 'wm' => sub { @@ -4135,8 +4248,7 @@ sub get_options{ $b_pci = 1; } if ($show{'usb'} || $show{'audio'} || $show{'network'} ){ - # to detect wan/lan, we have to use long form to get as much data as possible - $usb_level = ($show{'usb'} || $show{'network'}) ? 2 : 1; + $b_usb = 1; } if ($bsd_type && ($show{'short'} || $show{'system'} || $show{'battery'} || $show{'cpu'} || $show{'cpu-basic'} || $show{'info'} || $show{'machine'} || $show{'process'} || $show{'ram'} || $show{'sensor'} ) ){ @@ -4332,7 +4444,7 @@ sub show_options { and detected)" ], ['2', '-t', '', "Adds memory use output to CPU (-xt c), and CPU use to memory (-xt m)." ], - ['2', '--usb', '', "For Devices, shows USB version/speed." ], + ['2', '--usb', '', "For Devices, shows USB version/speed and driver." ], ); push @data, @rows; if ( $b_weather ){ @@ -4374,23 +4486,26 @@ sub show_options { @rows = ( ['1', '-xxx', '--extra 3', "Show extra, extra, extra data (only works with verbose or line output, not short form):" ], - ['2', '-A', '', "Specific vendor/product information (if relevant)." ], + ['2', '-A', '', "Specific vendor/product information (if relevant), serial number." ], ['2', '-B', '', "Chemistry, cycles, location (if available)." ], ['2', '-C', '', "CPU boost (turbo) enabled/disabled, if present." ], ['2', '-D', '', "Firmware rev. if available; partition scheme, in some cases; disk rotation speed (if detected)." ], - ['2', '-G', '', "Specific vendor/product information (if relevant)." ], + ['2', '-G', '', "Specific vendor/product information (if relevant); compositor + version (if detectable)." ], ['2', '-I', '', "For 'Shell:' adds ([su|sudo|login]) to shell name if present; for 'running in:' adds (SSH) if SSH session." ], ['2', '-m', '', "Width of memory bus, data and total (if present and greater than data); Detail for Type, if present; module voltage, if available; serial number." ], + ['2', '-N', '', "Serial number." ], ['2', '-R', '', "zfs-raid: portion allocated (used) by RAID devices/arrays. md-raid: system md-raid support types (kernel support, read ahead, RAID events). Hardware RAID rev, ports, specific vendor/product information." ], - ['2', '-S', '', "Panel/tray/bar info in desktop output, if in X (like lxpanel, + ['2', '-S', '', "Panel/tray/bar/dock info in desktop output, if in X (like lxpanel, xfce4-panel, mate-panel); (if available) dm version number, window manager - version number." ] + version number." ], + ['2', '--usb', '', "For devices: serial number (if present), interface count." ], ); push @data, @rows; if ( $b_weather ){ @@ -4479,6 +4594,8 @@ sub show_options { ['1', '', '--sleep', "[0-x.x] Change CPU sleep time, in seconds, for -C (default:^$cpu_sleep). Allows system to catch up and show a more accurate CPU use. Example:^$self_name^-Cxxx^--sleep^0.15" ], + ['1', '', '--usb-sys', "Force USB data to use /sys as data source (Linux only)." ], + ['1', '', '--usb-tool', "Force USB data to use lsusb as data source (Linux only)." ], ['1', '', '--wm', "Force wm: to use wmctrl as data source. Default uses ps." ], ['0', '', '', $line ], ['0', '', '', "Debugging Options:" ], @@ -4948,10 +5065,11 @@ sub clean_characters { # etc/issue often has junk stuff like (\l) \n \l return if ! $data; $data =~ s/[:\47]|\\[a-z]|\n|,|\"|\*|\||\+|\[\s\]|n\/a|\s\s+/ /g; - $data =~ s/\(\)//; + $data =~ s/\(\s*\)//; $data =~ s/^\s+|\s+$//g; return $data; } + sub cleaner { my ($item) = @_; return $item if !$item;# handle cases where it was 0 or '' @@ -5164,9 +5282,9 @@ sub row_defaults { 'partition-data' => "No Partition data was found.", 'pci-advanced-data' => 'bus/chip ids unavailable', 'pci-card-data' => "No PCI card data found.", - 'pci-slot-data' => "No PCI slot data found. SBC?", + 'pci-slot-data' => "No PCI slot data found.", 'raid-data' => "No RAID data was found.", - 'ram-data' => "No RAM data was found. SBC?", + 'ram-data' => "No RAM data was found.", 'root-required' => "", 'sensors-data-ipmi' => "No ipmi sensors data was found.", 'sensors-data-linux' => "No sensors data was found. Is sensors configured?", @@ -5700,7 +5818,7 @@ sub card_data { $card = main::pci_long_filter($card); } @data = ({ - main::key($num++,'Card') => $card, + main::key($num++,'Device') => $card, },); @rows = (@rows,@data); if ($extra > 2 && $b_pci_tool && $row[11]){ @@ -5758,7 +5876,7 @@ sub asound_data { $j = scalar @rows; $driver ||= 'N/A'; @data = ({ - main::key($num++,'Card') => $card, + main::key($num++,'Device') => $card, main::key($num++,'driver') => $driver, },); @rows = (@rows,@data); @@ -5776,7 +5894,7 @@ sub asound_data { } sub usb_data { eval $start if $b_log; - my (@rows,@data,@ids,$driver,$product,$product2,@temp2,$vendor,$vendor2); + my (@rows,@data,@ids,$driver,$path_id,$product,@temp2); my ($j,$num) = (0,1); if (-d '/proc/asound') { # note: this will double the data, but it's easier this way. @@ -5799,69 +5917,30 @@ sub usb_data { foreach my $ref (@usb){ my @row = @$ref; # a device will always be the second or > device on the bus - if ($row[1] > 1 && $row[2] eq $id){ + if ($row[1] > 1 && $row[7] eq $id){ $num = 1; # makre sure to reset, or second device trips last flag - ($product,$product2,$vendor,$vendor2) = ('','','',''); - if ($usb_level == 1){ - $product = main::cleaner($row[3]); - } - else { - foreach my $line (@row){ - my @working = split /:/, $line; - if ($working[0] eq 'idVendor' && $working[2]){ - $vendor = main::cleaner($working[2]); - } - if ($working[0] eq 'idProduct' && $working[2]){ - $product = main::cleaner($working[2]); - } - if ($working[0] eq 'iManufacturer' && $working[2]){ - $vendor2 = main::cleaner($working[2]); - } - if ($working[0] eq 'iProduct' && $working[2]){ - $product2 = main::cleaner($working[2]); - } - if ($working[0] eq 'Descriptor_Configuration'){ - last; - } - } - } - if ($vendor && $product){ - $product = ($product =~ /$vendor/) ? $product: "$vendor $product" ; - } - elsif (!$product) { - if ($vendor && $product2){ - $product = ($product2 =~ /$vendor/) ? $product2: "$vendor $product2" ; - } - elsif ($vendor2 && $product2){ - $product = ($product2 =~ /$vendor2/) ? $product2: "$vendor2 $product2" ; - } - elsif ($vendor){ - $product = $vendor; - } - elsif ($vendor2){ - $product = $vendor2; - } - else { - $product = 'N/A'; - } - } - @temp2 = main::get_usb_drivers($row[0],$row[2]) if !$bsd_type && -d "/sys/devices"; - if (@temp2 && $temp2[0]){ - $driver = $temp2[0]; - } + ($driver,$path_id,$product) = ('','',''); + $product = main::cleaner($row[13]) if $row[13]; + $driver = $row[15] if $row[15]; + $path_id = $row[2] if $row[2]; + $product ||= 'N/A'; $driver ||= 'snd-usb-audio'; @data = ({ - main::key($num++,'Card') => $product, + main::key($num++,'Device') => $product, main::key($num++,'type') => 'USB', main::key($num++,'driver') => $driver, },); @rows = (@rows,@data); if ($extra > 0){ - $rows[$j]{main::key($num++,'bus ID')} = "$row[0]:$row[1]"; + $rows[$j]{main::key($num++,'bus ID')} = "$path_id:$row[1]"; } if ($extra > 1){ - $rows[$j]{main::key($num++,'chip ID')} = $row[2]; + $row[7] ||= 'N/A'; + $rows[$j]{main::key($num++,'chip ID')} = $row[7]; + } + if ($extra > 2 && $row[16]){ + $rows[$j]{main::key($num++,'serial')} = main::apply_filter($row[16]); } } } @@ -6370,12 +6449,12 @@ sub create_output_full { main::key($num++,'model') => $cpu{'model_name'}, },); @rows = (@rows,@data); - if ($cpu{'arm-cpus'}){ - my $ref = $cpu{'arm-cpus'}; - my %arm_cpus = %$ref; + if ($cpu{'system-cpus'}){ + my $ref = $cpu{'system-cpus'}; + my %system_cpus = %$ref; my $i = 1; - my $counter = ( %arm_cpus && scalar keys %arm_cpus > 1 ) ? '-' : ''; - foreach my $key (keys %arm_cpus){ + my $counter = ( %system_cpus && scalar keys %system_cpus > 1 ) ? '-' : ''; + foreach my $key (keys %system_cpus){ $counter = '-' . $i++ if $counter; $rows[$j]{main::key($num++,'variant'.$counter)} = $key; } @@ -6608,7 +6687,8 @@ sub data_cpuinfo { # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/intel/2-1-core-xeon-vm-vs2017.txt"; # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/intel/4-1-core-xeon-vps-frodo1.txt"; # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/intel/4-6-core-xeon-no-mt-lathander.txt"; - #$file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/mips/mips-mainusg-cpuinfo.txt"; + # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/mips/mips-mainusg-cpuinfo.txt"; + # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/ppc/ppc-debian-ppc64-cpuinfo.txt"; my %speeds = set_cpu_speeds_sys(); my @cpuinfo = main::reader($file); my @phys_cpus = (0);# start with 1 always @@ -6687,11 +6767,15 @@ sub data_cpuinfo { $cpu{'arch'} = $line[1]; } } - elsif (!$cpu{'rev'} && ($line[0] eq 'stepping' || $line[0] eq 'cpu revision' )){ + elsif (!$cpu{'rev'} && ($line[0] eq 'stepping' || $line[0] eq 'cpu revision')){ $cpu{'rev'} = uc(sprintf("%x", $line[1])); } + # ppc + elsif (!$cpu{'rev'} && $line[0] eq 'revision'){ + $cpu{'rev'} = $line[1]; + } # this is hex so uc for cpu arch id - elsif (!$cpu{'model_id'} && $line[0] eq 'model' ){ + elsif (!$cpu{'model_id'} && (!$b_ppc && $line[0] eq 'model') ){ $cpu{'model_id'} = uc(sprintf("%x", $line[1])); } elsif (!$cpu{'model_id'} && $line[0] eq 'cpu variant' ){ @@ -6720,7 +6804,7 @@ sub data_cpuinfo { $cpu{'type'} = 'mips'; } } - elsif ( $line[0] eq 'cpu mhz' ){ + elsif ( $line[0] eq 'cpu mhz' || $line[0] eq 'clock' ){ $speed = speed_cleaner($line[1]); $cpu{'processors'}[$proc_count-1] = $speed; #$ids[$phys_id][$die_id] = ([($speed)]); @@ -6805,22 +6889,23 @@ sub data_cpuinfo { } $cpu{'phys'} = scalar @phys_cpus; $cpu{'dies'} = $die_id++; # count starts at 0, all cpus have 1 die at least - if ($b_arm){ + if ($b_arm || $b_mips){ if ($cpu{'dies'} <= 1){ my $arm_dies = cpu_dies_sys(); # case were 4 core arm returned 4 sibling lists, obviously wrong $cpu{'dies'} = $arm_dies if $arm_dies && $proc_count != $arm_dies; } - $cpu{'type'} = 'arm' if !$cpu{'type'}; + $cpu{'type'} = ($b_arm) ? 'arm' : 'mips' if !$cpu{'type'}; if (!$bsd_type){ - my %arm_cpus = arm_cpu_name(); - $cpu{'arm-cpus'} = \%arm_cpus if %arm_cpus; + my %system_cpus = system_cpu_name(); + $cpu{'system-cpus'} = \%system_cpus if %system_cpus; } } $cpu{'ids'} = (\@ids); if ( $extra > 0 && !$cpu{'arch'} && $type ne 'short' ){ $cpu{'arch'} = cpu_arch($cpu{'type'},$cpu{'family'},$cpu{'model_id'}); - $cpu{'arch'} = $cpu_arch if (!$cpu{'arch'} && $cpu_arch && ($b_mips || $b_arm)) + # cpu_arch comes from set_os() + $cpu{'arch'} = $cpu_arch if (!$cpu{'arch'} && $cpu_arch && ($b_mips || $b_arm || $b_ppc)); #print "$cpu{'type'},$cpu{'family'},$cpu{'model_id'},$cpu{'arch'}\n"; } if (!$speeds{'cur-freq'}){ @@ -7397,7 +7482,7 @@ sub get_boost_status { eval $end if $b_log; return $boost; } -sub arm_cpu_name { +sub system_cpu_name { eval $start if $b_log; my (%cpus,$compat,@working); if (@working = main::globber('/sys/firmware/devicetree/base/cpus/cpu@*/compatible')){ @@ -7495,6 +7580,9 @@ sub cpu_arch { if ($family ne ''){$arch="ARMv$family";} else {$arch='ARM';} } +# elsif ( $type eq 'ppc'){ +# $arch='PPC'; +# } # aka VIA elsif ( $type eq 'centaur'){ if ($family eq '5'){ @@ -8316,10 +8404,12 @@ sub device_vendor { # must come before samsung MU. NOTE: toshiba can have: TOSHIBA_MK6475GSX: mush: MKNSSDCR120GB_ ['(^MKN|Mushkin)','Mushkin','Mushkin',''], # MKNS # MU = Multiple_Flash_Reader too risky: |M[UZ][^L] - ['(SAMSUNG|^MCG[0-9]+GC)','SAMSUNG','Samsung',''], # maybe ^SM - ['(SanDisk|^SDS[S]?[DQ]|^SL([0-9]+)G|^AFGCE|ULTRA\sFIT|Cruzer)','SanDisk','SanDisk',''], - ['(^ST[^T]|[S]?SEAGATE|^X[AFP]|^BUP|Expansion Desk)','[S]?SEAGATE','Seagate',''], # real, SSEAGATE Backup+; XP1600HE30002 - ['^(WD|Western Digital|My (Book|Passport)|00LPCX|Elements)','(^WDC|Western Digital)','Western Digital',''], + ['(SAMSUNG|^MCG[0-9]+GC|^G2 Portable)','SAMSUNG','Samsung',''], # maybe ^SM + ['(SanDisk|^SDS[S]?[DQ]|^SL([0-9]+)G|^AFGCE|ULTRA\sFIT|Clip Sport|Cruzer)','SanDisk','SanDisk',''], + ['^STEC\b','^STEC\b','STEC',''], # ssd drive, must come before seagate ST test + # real, SSEAGATE Backup+; XP1600HE30002 + ['(^ST[^T]|[S]?SEAGATE|^X[AFP]|^BUP|Expansion Desk|GoFlex)','[S]?SEAGATE','Seagate',''], + ['^(WD|Western Digital|My (Book|Passport)|\d*LPCX|Elements|M000|EARX|EFRX|\d*EAVS)','(^WDC|Western Digital)','Western Digital',''], ## Then better known ones ## ['^(A-DATA|ADATA|AXN)','^(A-DATA|ADATA)','A-Data',''], ['^ADTRON','^(ADTRON)','Adtron',''], @@ -8328,10 +8418,10 @@ sub device_vendor { ['^(Corsair|Voyager)','^Corsair','Corsair',''], ['^(FUJITSU|MP)','^FUJITSU','Fujitsu',''], # note: 2012: wdc bought hgst - ['^(HGST)','^HGST','HGST (Hitachi)',''], # HGST HUA + ['^(HGST|Touro)','^HGST','HGST (Hitachi)',''], # HGST HUA ['^(Hitachi|HDS|HDT|IC|HT|HU)','^Hitachi','Hitachi',''], ['^Hoodisk','^Hoodisk','Hoodisk',''], - ['^(HP\b)','^HP','HP',''], # vb: VB0250EAVER but clashes with vbox; HP_SSD_S700_120G + ['^(HP\b|MB0)','^HP','HP',''], # vb: VB0250EAVER but clashes with vbox; HP_SSD_S700_120G ['^(LSD|Lexar|JumpDrive)','^Lexar','Lexar',''], # mmc-LEXAR_0xb016546c # OCZSSD2-2VTXE120G is OCZ-VERTEX2_3.5 ['^(OCZ|APOC|D2|DEN|DEN|DRSAK|EC188|FTNC|GFGC|MANG|MMOC|NIMC|NIMR|PSIR|TALOS2|TMSC|TRSAK)','^OCZ[\s\-]','OCZ',''], @@ -8341,7 +8431,7 @@ sub device_vendor { ['^PNY','^PNY\s','PNY','','^PNY'], # note: get rid of: M[DGK] becasue mushkin starts with MK # note: seen: KXG50ZNV512G NVMe TOSHIBA 512GB | THNSN51T02DUK NVMe TOSHIBA 1024GB - ['(^[S]?TOS|^THN|TOSHIBA)','[S]?TOSHIBA','Toshiba',''], # scsi-STOSHIBA_STOR.E_EDITION_ + ['(^[S]?TOS|^THN|TOSHIBA|TransMemory)','[S]?TOSHIBA','Toshiba',''], # scsi-STOSHIBA_STOR.E_EDITION_ ## These go last because they are short and could lead to false ID, or are unlikely ## ['^Android','^Android','Android',''], # must come before AP|Apacer @@ -8350,9 +8440,10 @@ sub device_vendor { ['^BUFFALO','^BUFFALO','Buffalo',''], ['^CHN\b','','Zheino',''], ['^Colorful\b','^Colorful','Colorful',''], + ['^DGM','^DGM\b','DGM',''], ['^DREVO\b','^DREVO','Drevo',''], ['^(Eaget|V8$)','^Eaget','Eaget',''], - ['^EXCELSTOR','^EXCELSTOR( TECHNOLOGY)?','Excelstor',''], + ['^EXCELSTOR','^EXCELSTOR( TECHNO(LOGY)?)?','Excelstor',''], ['^FASTDISK','^FASTDISK','FASTDISK',''], ['^FORESEE','^FORESEE','Foresee',''], ['^GALAX\b','^GALAX','GALAX',''], @@ -8364,25 +8455,29 @@ sub device_vendor { ['^(G[\.]?SKILL)','^G[\.]?SKILL','G.SKILL',''], ['^HUAWEI','^HUAWEI','Huawei',''], ['^(IBM|DT)','^IBM','IBM',''], - ['^Imation','^Imation(\sImation)?','Imation',''], # Imation_ImationFlashDrive + ['^Imation','^Imation(\sImation)?','Imation',''], # Imation_ImationFlashDrive; TF20 is imation/tdk ['^(InnoDisk|Innolite)','^InnoDisk( Corp.)?','InnoDisk',''], ['^Innostor','^Innostor','Innostor',''], - ['^(Intenso|Rainbow Line)','^Intenso','Intenso',''], + ['^(Intenso|(Rainbow|Speed) Line)','^Intenso','Intenso',''], ['^KingDian','^KingDian','KingDian',''], + ['^Kingfast','^Kingfast','Kingfast',''], ['^KingMAX','^KingMAX','KingMAX',''], ['^KINGSHARE','^KINGSHARE','KingShare',''], ['^(LITE[\-]?ON[\s\-]?IT)','^LITE[\-]?ON[\s\-]?IT','LITE-ON IT',''], # LITEONIT_LSS-24L6G ['^(LITE[\-]?ON|PH6)','^LITE[\-]?ON','LITE-ON',''], # PH6-CE240-L ['^M-Systems','^M-Systems','M-Systems',''], - ['^MAXTOR','^MAXTOR','Maxtor',''], + ['^(MAXTOR)','^MAXTOR','Maxtor',''], # note M3 is usually maxtor, but can be samsung ['^(MT|M5|Micron)','^Micron','Micron',''], ['^MARVELL','^MARVELL','Marvell',''], ['^Medion','^Medion','Medion',''], ['^Motorola','^Motorola','Motorola',''], + ['^PALIT','PALIT','Palit',''], # ssd ['^(PS[8F]|Patriot)','^Patriot','Patriot',''], ['^PIX[\s]?JR','^PIX[\s]?JR','Disney',''], ['^(PLEXTOR|PX-)','^PLEXTOR','Plextor',''], + ['QEMU','^[0-9]*QEMU( QEMU)?','QEMU',''], # 0QUEMU QEMU HARDDISK ['(^Quantum|Fireball)','^Quantum','Quantum',''], + ['^QUMO','^QUMO','Qumo',''], ['^R3','','AMD Radeon',''], # ssd ['^RENICE','^RENICE','Renice',''], ['^RIM[\s]','^RIM','RIM',''], @@ -8401,8 +8496,11 @@ sub device_vendor { ['^(SF|Swissbit)','^Swissbit','Swissbit',''], # ['^(SUPERSPEED)','^SUPERSPEED','SuperSpeed',''], # superspeed is a generic term ['^TANDBERG','^TANDBERG','Tanberg',''], + ['^TCSUNBOW','^TCSUNBOW','TCSunBow',''], ['^TEAC','^TEAC','TEAC',''], + ['^TEAM','^TEAM( Group)?','Team',''], ['^(TS|Transcend|JetFlash)','^Transcend','Transcend',''], + # Twister Line but if we slice out Twister it would just say Line ['^TrekStor','^TrekStor','TrekStor',''], ['^UDinfo','^UDinfo','UDinfo',''], ['^(UG|Unigen)','^Unigen','Unigen',''], @@ -8598,6 +8696,7 @@ sub get { eval $end if $b_log; return @rows; } +# @pci: # 0 type # 1 type_id # 2 bus_id @@ -8635,7 +8734,7 @@ sub card_data { $card = main::pci_long_filter($card); } @data = ({ - main::key($num++,'Card') => $card, + main::key($num++,'Device') => $card, },); @rows = (@rows,@data); if ($extra > 2 && $b_pci_tool && $row[11]){ @@ -8695,6 +8794,10 @@ sub display_data(){ # initial tests, if wayland, it is certainly a compositor $protocol = lc($protocol) if $protocol; $graphics{'compositor'} = display_compositor($protocol); + # gnome-shell is incredibly slow to return version + if ($extra > 2 && $graphics{'compositor'} && (!$show{'system'} || $graphics{'compositor'} ne 'gnome-shell' ) ){ + $graphics{'compositor-version'} = (main::program_data($graphics{'compositor'},$graphics{'compositor'},3))[1]; + } } if ( $b_display){ # X vendor and version detection. @@ -8794,7 +8897,12 @@ sub display_data(){ $server_string = "$graphics{'vendor'}$version"; } elsif ($graphics{'version'}) { - $server_string = "X.org $graphics{'version'}"; + if ($graphics{'version'} =~ /^Xvesa/){ + $server_string = $graphics{'version'}; + } + else { + $server_string = "X.org $graphics{'version'}"; + } } if ($graphics{'screens'}){ my $ref = $graphics{'screens'}; @@ -8835,6 +8943,9 @@ sub display_data(){ } if ($graphics{'compositor'}){ $row[0]{main::key($num++,'compositor')} = $graphics{'compositor'}; + if ($graphics{'compositor-version'}){ + $row[0]{main::key($num++,'v')} = $graphics{'compositor-version'}; + } } } if ($resolution){ @@ -9094,6 +9205,9 @@ sub x_version { elsif ($program = main::check_program('X')){ @data = main::grabber("$program -version 2>&1"); } + elsif ($program = main::check_program('Xvesa')){ + @data = main::grabber("$program -version 2>&1"); + } #print join('^ ', @paths), " :: $program\n"; #print Data::Dumper::Dumper \@data; if (@data){ @@ -9106,6 +9220,11 @@ sub x_version { $version = (split /\s+/, $_)[4]; last; } + elsif (/^Xvesa from/i) { + $version = (split /\s+/, $_)[3]; + $version = "Xvesa $version" if $version; + last; + } } } # remove extra X paths @@ -9122,8 +9241,12 @@ sub display_compositor { if (@ps_gui){ # 1 check program; 2 search; 3 unused version; 4 print my @compositors = ( + ['asc','asc','','asc'], ['budgie-wm','budgie-wm','','budgie-wm'], + # owned by: compiz-core in debian + ['compiz','compiz','','compiz'], ['compton','compton','','compton'], + # as of version 20 is wayland compositor ['enlightenment','enlightenment','','enlightenment'], ['gnome-shell','gnome-shell','','gnome-shell'], ['kwin_wayland','kwin_wayland','','kwin wayland'], @@ -9133,21 +9256,28 @@ sub display_compositor { ['muffin','muffin','','muffin'], ['mutter','mutter','','mutter'], ['weston','weston','','weston'], - # owned by: compiz-core in debian - ['compiz','compiz','','compiz'], - # did not find follwing in debian apt + # these are more obscure, so check for them last ['3dwm','3dwm','','3dwm'], + ['dcompmgr','dcompmgr','','dcompmgr'], ['dwc','dwc','','dwc'], + ['fireplace','fireplace','','fireplace'], ['grefson','grefson','','grefson'], - ['ireplace','ireplace','','ireplace'], ['kmscon','kmscon','','kmscon'], + ['liri','liri','','liri'], ['metisse','metisse','','metisse'], ['mir','mir','','mir'], ['moblin','moblin','','moblin'], + ['motorcar','motorcar','','motorcar'], + ['orbital','orbital','','orbital'], + ['papyros','papyros','','papyros'], + ['perceptia','perceptia','','perceptia'], ['rustland','rustland','','rustland'], + ['sommelier','sommelier','','sommelier'], ['sway','sway','','sway'], ['swc','swc','','swc'], ['unagi','unagi','','unagi'], + ['way-cooler','way-cooler','','way-cooler'], + ['wavy','wavy','','wavy'], ['wayhouse','wayhouse','','wayhouse'], ['westford','westford','','westford'], ['xcompmgr','xcompmgr','','xcompmgr'], @@ -9207,7 +9337,7 @@ sub get { } elsif (!$bsd_type) { # this uses /proc/cpuinfo so only GNU/Linux - if ($b_arm || $b_mips){ + if ($b_arm || $b_mips || $b_ppc){ %soc_machine = machine_data_soc(); @data = create_output_soc(%soc_machine) if %soc_machine; } @@ -9356,15 +9486,17 @@ sub create_output { return @rows; } sub create_output_soc { - my (%data,@row,@rows); my (%soc_machine) = @_; + my ($key,%data,@row,@rows); my $num = 0; my $j = 0; #print Data::Dumper::Dumper \%soc_machine; # this is sketchy, /proc/device-tree/model may be similar to Hardware value from /proc/cpuinfo # raspi: Hardware : BCM2835 model: Raspberry Pi Model B Rev 2 if ($soc_machine{'device'} || $soc_machine{'model'}){ - my $key = ($b_arm) ? 'ARM Device': 'MIPS Device'; + if ($b_arm){$key = 'ARM Device'} + elsif ($b_mips){$key = 'MIPS Device'} + elsif ($b_ppc){$key = 'PowerPC Device'} $rows[$j]{main::key($num++,'Type')} = $key; my $system = 'System'; if (defined $soc_machine{'model'}){ @@ -9827,7 +9959,7 @@ sub get { # shift @ifs_found; # pop @ifs_found; if (!$bsd_type){ - @data = advanced_data_sys('check','',0,'',''); + @data = advanced_data_sys('check','',0,'','',''); @rows = (@rows,@data) if @data; } else { @@ -9863,7 +9995,7 @@ sub card_data { #print "$row[0] $row[3]\n"; # NOTE: class 06 subclass 80 # https://www-s.acm.illinois.edu/sigops/2007/roll_your_own/7.c.1.html - if (($row[0] && $row[0] =~ /^(eth|ethernet|ethernet-phy|network|wifi|wlan)$/ )|| ($row[1] && $row[1] eq '0680' ) ){ + if (($row[0] && $row[0] =~ /^(eth|ethernet|ethernet-phy|lan|l-lan|network|wifi|wlan)$/ )|| ($row[1] && $row[1] eq '0680' ) ){ #print "$row[0] $row[3]\n"; $j = scalar @rows; my $driver = $row[9]; @@ -9882,7 +10014,7 @@ sub card_data { #$card ||= 'N/A'; $driver ||= 'N/A'; @data = ({ - main::key($num++,'Card') => $card, + main::key($num++,'Device') => $card, },); @rows = (@rows,@data); #if ($extra > 2 && $b_pci_tool && $row[11]){ @@ -9893,6 +10025,12 @@ sub card_data { $rows[$j]{main::key($num++,'type')} = 'network bridge'; } $rows[$j]{main::key($num++,'driver')} = $driver; + my $bus_id = 'N/A'; + # note: for arm/mips we want to see the single item bus id, why not? + # note: we can have bus id: 0002 / 0 which is valid, but 0 / 0 is invalid + if (defined $row[2] && $row[2] ne '0' && defined $row[3]){$bus_id = "$row[2].$row[3]"} + elsif (defined $row[2] && $row[2] ne '0'){$bus_id = $row[2]} + elsif (defined $row[3] && $row[3] ne '0'){$bus_id = $row[3]} if ($extra > 0){ if ($row[9] && !$bsd_type){ my $version = main::get_module_version($row[9]); @@ -9902,11 +10040,6 @@ sub card_data { $row[8] ||= 'N/A'; # as far as I know, wifi has no port, but in case it does in future, use it $rows[$j]{main::key($num++,'port')} = $row[8] if (!$b_wifi || ( $b_wifi && $row[8] ne 'N/A') ); - my $bus_id = 'N/A'; - # note: for arm/mips we want to see the single item bus id, why not? - if ($row[2] && $row[3]){$bus_id = "$row[2].$row[3]"} - elsif ($row[2]){$bus_id = $row[2]} - elsif ($row[3]){$bus_id = $row[3]} $rows[$j]{main::key($num++,'bus ID')} = $bus_id; } if ($extra > 1){ @@ -9914,7 +10047,7 @@ sub card_data { } if ($show{'network-advanced'}){ if (!$bsd_type){ - @data = advanced_data_sys($row[5],$row[6],$holder{$chip_id},$b_wifi,''); + @data = advanced_data_sys($row[5],$row[6],$holder{$chip_id},$b_wifi,'',$bus_id); } else { @data = advanced_data_bsd("$row[9]$row[11]",$b_wifi); @@ -9941,83 +10074,46 @@ sub card_data { } sub usb_data { eval $start if $b_log; - my (@data,@rows,@temp2,$b_wifi,$driver,$path,$product,$product2,$test,$vendor,$vendor2); + my (@data,@rows,@temp2,$b_wifi,$driver, + $path,$path_id,$product,$test,$type); my ($j,$num) = (0,1); return if !@usb; foreach my $ref (@usb){ my @row = @$ref; - # a device will always be the second or > device on the bus - if ($row[1] > 1){ + # a device will always be the second or > device on the bus, except for + # daisychained hubs + if ($row[1] > 1 && $row[4] ne '9'){ $num = 1; - ($product,$product2,$test,$vendor,$vendor2) = ('','','','',''); - if ($usb_level == 1){ - $product = main::cleaner($row[3]); - } - else { - foreach my $line (@row){ - my @working = split /:/, $line; - if ($working[0] eq 'idVendor' && $working[2]){ - $vendor = main::cleaner($working[2]); - } - if ($working[0] eq 'idProduct' && $working[2]){ - $product = main::cleaner($working[2]); - } - if ($working[0] eq 'iVendor' && $working[2]){ - $product2 = main::cleaner($working[2]); - } - if ($working[0] eq 'iProduct' && $working[2]){ - $product2 = main::cleaner($working[2]); - } - if ($working[0] eq 'Descriptor_Configuration'){ - last; - } - } - if ($vendor && $product){ - $product = ($product =~ /$vendor/) ? $product: "$vendor $product"; - } - elsif ($vendor && $product2){ - $product = ($product2 =~ /$vendor/) ? $product2: "$vendor $product2"; - } - elsif ($vendor2 && $product){ - $product = ($product =~ /$vendor2/) ? $product: "$vendor2 $product"; - } - elsif ($vendor2 && $product2){ - $product = ($product2 =~ /$vendor2/) ? $product2: "$vendor2 $product2"; - } - elsif ($vendor){ - $product = $vendor; - } - elsif ($vendor2){ - $product = $vendor2; - } - $test = "$vendor $product $vendor2 $vendor2"; - } + ($driver,$path,$path_id,$product,$test,$type) = ('','','','','',''); + $product = main::cleaner($row[13]) if $row[13]; + $driver = $row[15] if $row[15]; + $path = $row[3] if $row[3]; + $path_id = $row[2] if $row[2]; + $test = "$driver $product $type"; if ($product && network_device($test)){ - @temp2 = main::get_usb_drivers($row[0],$row[2]) if !$bsd_type && -d "/sys/devices"; - if (@temp2){ - $driver = $temp2[0] if $temp2[0]; - $path = $temp2[1] if $temp2[1]; - } $driver ||= 'usb-network'; @data = ({ - main::key($num++,'Card') => $product, + main::key($num++,'Device') => $product, main::key($num++,'type') => 'USB', main::key($num++,'driver') => $driver, },); $b_wifi = check_wifi($product); @rows = (@rows,@data); if ($extra > 0){ - $rows[$j]{main::key($num++,'bus ID')} = "$row[0]:$row[1]"; + $rows[$j]{main::key($num++,'bus ID')} = "$path_id:$row[1]"; } if ($extra > 1){ - $rows[$j]{main::key($num++,'chip ID')} = $row[2]; + $rows[$j]{main::key($num++,'chip ID')} = $row[7]; + } + if ($extra > 2 && $row[16]){ + $rows[$j]{main::key($num++,'serial')} = main::apply_filter($row[16]); } if ($show{'network-advanced'}){ if (!$bsd_type){ my (@temp,$vendor,$chip); - @temp = split (/:/, $row[2]) if $row[2]; + @temp = split (/:/, $row[7]) if $row[7]; ($vendor,$chip) = ($temp[0],$temp[1]) if @temp; - @data = advanced_data_sys($vendor,$chip,0,$b_wifi,$path); + @data = advanced_data_sys($vendor,$chip,0,$b_wifi,$path,''); } # NOTE: we need the driver.number, like wlp0 to get a match, and # we can't get that from usb data, so we have to let it fall back down @@ -10037,7 +10133,7 @@ sub usb_data { sub advanced_data_sys { eval $start if $b_log; return if ! -d '/sys/class/net'; - my ($vendor,$chip,$count,$b_wifi,$path_usb) = @_; + my ($vendor,$chip,$count,$b_wifi,$path_usb,$bus_id) = @_; my $num = 0; my $key = 'IF'; my ($b_check,$b_usb,$if,$path,@paths,@row,@rows); @@ -10064,7 +10160,7 @@ sub advanced_data_sys { my ($data1,$data2,$duplex,$mac,$speed,$state); # for usb, we already know where we are if (!$b_usb){ - if (!$b_arm || $b_pci_tool ){ + if (( !$b_arm && !$b_ppc) || $b_pci_tool ){ $path = "$_/device/vendor"; $data1 = (main::reader($path))[0] if -e $path; $data1 =~ s/^0x// if $data1; @@ -10074,7 +10170,7 @@ sub advanced_data_sys { # this is a fix for a redhat bug in virtio $data2 = (defined $data2 && $data2 eq '0001' && defined $chip && $chip eq '1000') ? '1000' : $data2; } - elsif ($b_arm) { + elsif ($b_arm || $b_ppc) { $path = Cwd::abs_path($_); $path =~ /($chip)/; if ($1){ @@ -10083,8 +10179,10 @@ sub advanced_data_sys { } } } - #print "d1:$data1 v:$vendor d2:$data2 c:$chip\n"; - if ( $b_usb || $b_check || ( $data1 && $data2 && $data1 eq $vendor && $data2 eq $chip )) { + # print "d1:$data1 v:$vendor d2:$data2 c:$chip bus_id: $bus_id\n"; + # print Cwd::abs_path($_), "\n" if $bus_id; + if ( $b_usb || $b_check || ( $data1 && $data2 && $data1 eq $vendor && $data2 eq $chip && + ( ($b_arm || $b_mips || $b_ppc || $b_sparc) || $bus_id && Cwd::abs_path($_) =~ /$bus_id\// ) )) { $if = $_; $if =~ s/^\/.+\///; # print "top: if: $if ifs: @ifs_found\n"; @@ -10347,9 +10445,9 @@ sub network_device { my ($device_string) = @_; my ($b_network); # belkin=050d; d-link=07d1; netgear=0846; ralink=148f; realtek=0bda; - # Atmel makes other stuff - my @tests = qw(wifi Wi-Fi.*Adapter Ethernet \bLAN\b WLAN Network 802\.11 - Wireless.*Adapter 54\sMbps Network 100\/1000 Mobile\sBroadband Atheros D-Link.*Adapter + # Atmel makes other stuff. NOTE: exclude 'networks': IMC Networks + my @tests = qw(wifi Wi-Fi.*Adapter Ethernet \bLAN\b WLAN Network\b Networking\b 802\.11 + Wireless.*Adapter 54\sMbps 100\/1000 Mobile\sBroadband Atheros D-Link.*Adapter Dell.*Wireless D-Link.*Wireless Linksys Netgea Ralink Realtek.*Network Realtek.*Wireless Belkin.*Wireless Actiontec.*Wireless AirLink.*Wireless Asus.*Wireless Buffalo.*Wireless Davicom DWA-.*RangeBooster DWA-.*Wireless @@ -10655,8 +10753,8 @@ sub optical_data_linux { $devices{$key}{'rev'} = (main::reader("$device/rev"))[0]; } } - elsif ( -e "/proc/ide/$_/model"){ - $devices{$key}{'vendor'} = (main::reader("/proc/ide/$_/model"))[0]; + elsif ( -e "/proc/ide/$key/model"){ + $devices{$key}{'vendor'} = (main::reader("/proc/ide/$key/model"))[0]; $devices{$key}{'vendor'} = main::cleaner($devices{$key}{'vendor'}); } if ($show{'optical'} && @info){ @@ -11246,13 +11344,20 @@ sub get { } sub cpu_processes { eval $start if $b_log; - my ($j,$num,$cpu,$cpu_mem,$mem) = (0,0,'','',''); - my (@processes); + my ($j,$num,$cpu,$cpu_mem,$mem,$pid) = (0,0,'','','',''); + my ($pid_col,@processes,@rows); my $count = ($b_irc)? 5: $ps_count; - my @rows = sort { + if ($ps_cols >= 10){ + @rows = sort { my @a = split(/\s+/,$a); my @b = split(/\s+/,$b); $b[2] <=> $a[2] } @ps_aux; + $pid_col = 1; + } + else { + @rows = @ps_aux; + $pid_col = 0 if $ps_cols == 2; + } # if there's a count limit, for irc, etc, only use that much of the data @rows = splice @rows,0,$count; @@ -11270,18 +11375,20 @@ sub cpu_processes { $num = 1; $j = scalar @processes; my @row = split /\s+/, $_; - my @command = process_starter(scalar @row, $row[10],$row[11]); + my @command = process_starter(scalar @row, $row[$ps_cols],$row[$ps_cols + 1]); + $cpu = ($ps_cols >= 10 ) ? $row[2] . '%': 'N/A'; @data = ({ main::key($num++,$i++) => '', - main::key($num++,'cpu') => $row[2] . '%', + main::key($num++,'cpu') => $cpu, main::key($num++,'command') => $command[0], },); @processes = (@processes,@data); if ($command[1]) { $processes[$j]{main::key($num++,'started by')} = $command[1]; } - $processes[$j]{main::key($num++,'pid')} = $row[1]; - if ($extra > 0){ + $pid = (defined $pid_col)? $row[$pid_col] : 'N/A'; + $processes[$j]{main::key($num++,'pid')} = $pid; + if ($extra > 0 && $ps_cols >= 10){ my $decimals = ($row[5]/1024 > 10 ) ? 1 : 2; $mem = (defined $row[5]) ? sprintf( "%.${decimals}f", $row[5]/1024 ) . ' MiB' : 'N/A'; $mem .= ' (' . $row[3] . '%)'; @@ -11294,13 +11401,20 @@ sub cpu_processes { } sub mem_processes { eval $start if $b_log; - my ($j,$num,$cpu,$cpu_mem,$mem) = (0,0,'','',''); - my (@data,@processes,$memory); + my ($j,$num,$cpu,$cpu_mem,$mem,$pid) = (0,0,'','','',''); + my (@data,$pid_col,@processes,$memory,@rows); my $count = ($b_irc)? 5: $ps_count; - my @rows = sort { + if ($ps_cols >= 10){ + @rows = sort { my @a = split(/\s+/,$a); my @b = split(/\s+/,$b); $b[5] <=> $a[5] } @ps_aux; + $pid_col = 1; + } + else { + @rows = @ps_aux; + $pid_col = 0 if $ps_cols == 2; + } @rows = splice @rows,0,$count; #print Data::Dumper::Dumper \@rows; @processes = main::memory_data_full('process') if !$b_mem; @@ -11318,10 +11432,15 @@ sub mem_processes { $num = 1; $j = scalar @processes; my @row = split /\s+/, $_; - my $decimals = ($row[5]/1024 > 10 ) ? 1 : 2; - $mem = ($row[5]) ? sprintf( "%.${decimals}f", $row[5]/1024 ) . ' MiB' : 'N/A'; - my @command = process_starter(scalar @row, $row[10],$row[11]); - $mem .= " (" . $row[3] . "%)"; + if ($ps_cols >= 10){ + my $decimals = ($row[5]/1024 > 10 ) ? 1 : 2; + $mem = ($row[5]) ? sprintf( "%.${decimals}f", $row[5]/1024 ) . ' MiB' : 'N/A'; + $mem .= " (" . $row[3] . "%)"; + } + else { + $mem = 'N/A'; + } + my @command = process_starter(scalar @row, $row[$ps_cols],$row[$ps_cols + 1]); @data = ({ main::key($num++,$i++) => '', main::key($num++,'mem') => $mem, @@ -11331,8 +11450,9 @@ sub mem_processes { if ($command[1]) { $processes[$j]{main::key($num++,'started by')} = $command[1]; } - $processes[$j]{main::key($num++,'pid')} = $row[1]; - if ($extra > 0){ + $pid = (defined $pid_col)? $row[$pid_col] : 'N/A'; + $processes[$j]{main::key($num++,'pid')} = $pid; + if ($extra > 0 && $ps_cols >= 10){ $cpu = $row[2] . '%'; $processes[$j]{main::key($num++,'cpu')} = $cpu; } @@ -11345,7 +11465,7 @@ sub process_starter { my ($count, $row10, $row11) = @_; my (@return); # note: [migration/0] would clear with a simple basename - if ($count > 11 && $row11 =~ /^\//){ + if ($count > ($ps_cols + 1) && $row11 =~ /^\// && $row11 !~ /^\/(tmp|temp)/){ $row11 =~ s/^\/.*\///; $return[0] = $row11; $row10 =~ s/^\/.*\///; @@ -12561,6 +12681,9 @@ sub get_repos_linux { my $portage_gentoo_dir = '/etc/portage-gentoo/repos.conf/'; my $slackpkg = '/etc/slackpkg/mirrors'; my $slackpkg_plus = '/etc/slackpkg/slackpkgplus.conf'; + my $slapt_get = '/etc/slapt-get/'; + my $tce_app = '/usr/bin/tce'; + my $tce_file = '/opt/tcemirror'; my $yum_conf = '/etc/yum.conf'; my $yum_repo_dir = '/etc/yum.repos.d/'; my $zypp_repo_dir = '/etc/zypp/repos.d/'; @@ -12725,12 +12848,19 @@ sub get_repos_linux { } } # slackware - if (-f $slackpkg || -f $slackpkg_plus){ + if (-f $slackpkg || -f $slackpkg_plus || -d $slapt_get){ #$slackpkg = "$ENV{HOME}/bin/scripts/inxi/data/repo/slackware/slackpkg-2.conf"; if (-f $slackpkg){ @data = repo_builder($slackpkg,'slackpkg','^[[:space:]]*[^#]+'); @rows = (@rows,@data); } + if (-d $slapt_get){ + @data2 = main::globber("${slapt_get}*"); + foreach my $file (@data2){ + @data = repo_builder($file,'slaptget','^\s*SOURCE','\s*=\s*',1); + @rows = (@rows,@data); + } + } if (-f $slackpkg_plus){ push @dbg_files, $slackpkg_plus if $debugger_dir; @data = main::reader($slackpkg_plus,'strip'); @@ -12912,6 +13042,11 @@ sub get_repos_linux { @data = repo_builder($apk,'apk','^\s*[^#]+'); @rows = (@rows,@data); } + # TinyCore + if (-e $tce_app || -f $tce_file){ + @data = repo_builder($tce_file,'tce','^\s*[^#]+'); + @rows = (@rows,@data); + } # Mandriva/Mageia using: urpmq if ( $path = main::check_program('urpmq') ){ @data2 = main::grabber("$path --list-media active --list-url","\n",'strip'); @@ -13144,6 +13279,8 @@ sub repo_builder { 'no-files' => 'No repo files found in', 'slackpkg' => 'No active slackpkg repos in', 'slackpkg+' => 'No active slackpkg+ repos in', + 'slaptget' => 'No active slapt-get repos in', + 'tce' => 'No active tce mirrors in', 'yum' => 'No active yum repos in', 'zypp' => 'No active zypp repos in', ); @@ -13165,16 +13302,20 @@ sub repo_builder { 'netbsd' => 'NetBSD pkg servers', 'slackpkg' => 'slackpkg repos in', 'slackpkg+' => 'slackpkg+ repos in', + 'slaptget' => 'slapt-get repos in', + 'tce' => 'Active tce mirrors in', 'yum' => 'Active yum repos in', 'zypp' => 'Active zypp repos in', ); $key = $keys{$type}; return $key if $file eq 'active'; push @dbg_files, $file if $debugger_dir; - @content = main::reader($file); - @content = grep {/$search/i && !/^\s*$/} @content if @content; - @content = data_cleaner(@content); - if ($split){ + if (-r $file){ + @content = main::reader($file); + @content = grep {/$search/i && !/^\s*$/} @content if @content; + @content = data_cleaner(@content) if @content; + } + if ($split && @content){ @content = map { my @inner = split (/$split/, $_); $inner[$count]; @@ -14462,7 +14603,7 @@ sub get { my $num = 0; my $ref = $alerts{'lsusb'}; my $ref2 = $alerts{'usbdevs'}; - if ( $$ref{'action'} ne 'use' && $$ref2{'action'} ne 'use'){ + if ( !@usb && $$ref{'action'} ne 'use' && $$ref2{'action'} ne 'use'){ if ($os eq 'linux' ){ $key1 = $$ref{'action'}; $val1 = $$ref{$key1}; @@ -14490,7 +14631,8 @@ sub get { sub usb_data { eval $start if $b_log; return if ! @usb; - my (@data,@row,@rows,$bus_id,$chip_id,$speed,$protocol,$class,$vendor,$product); + my (@data,@rows); + my ($b_hub,$bus_id,$chip_id,$driver,$path_id,$ports,$product,$serial,$speed,$type); my $num = 0; my $j = 0; # note: the data has been presorted in set_lsusb_data by: @@ -14499,113 +14641,57 @@ sub usb_data { my @id = @$ref; $j = scalar @rows; $num = 1; - $bus_id = "$id[0]:$id[1]"; - $chip_id = $id[2]; - my $b_hub = 0; + $chip_id = $id[7]; + $b_hub = 0; + ($driver,$path_id,$ports,$product, + $serial,$speed,$type) = ('','','','','','',''); + $speed = ( main::is_numeric($id[8]) ) ? sprintf("%1.1f",$id[8]) : $id[8] if $id[8]; + $product = main::cleaner($id[13]) if $id[13]; + $serial = main::apply_filter($id[16]) if $id[16]; + $product ||= 'N/A'; + $speed ||= 'N/A'; + $path_id = $id[2] if $id[2]; + $bus_id = "$path_id:$id[1]"; # it's a hub - if ($id[1] == 1){ - foreach my $line (@id){ - #print "$line\n"; - @row = split /:/, $line; - next if ! defined $row[0]; - if ($row[0] eq 'bcdUSB' && defined $row[1]){ - $speed = ( main::is_numeric($row[1]) ) ? sprintf("%1.1f",$row[1]) : $row[1]; - } - elsif ($row[0] eq '~bInterfaceProtocol' && $row[2] ){ - $protocol = $row[2]; - } - } - $protocol ||= 'N/A'; - $speed ||= 'N/A'; + if ($id[4] eq '9'){ + $ports = $id[10] if $id[10]; + $ports ||= 'N/A'; #print "pt0:$protocol\n"; @data = ({ main::key($num++,'Hub') => $bus_id, main::key($num++,'usb') => $speed, - main::key($num++,'type') => $protocol, + main::key($num++,'type') => $product, + main::key($num++,'ports') => $ports, },); @rows = (@rows,@data); - if ($extra > 1){ - $rows[$j]{main::key($num++,'chip ID')} = $chip_id; - } + $b_hub = 1; } # it's a device else { - ($class,$product,$protocol,$vendor,$speed) = ('','','','',''); - foreach my $line (@id){ - @row = split /:/, $line; - next if ! defined $row[0]; - if ($row[0] eq 'bcdUSB' && defined $row[1]){ - $speed = sprintf("%.1f",$row[1]); - } - elsif ($row[0] eq 'bDeviceClass' && defined $row[1] && $row[1] == 9){ - $b_hub = 1; - } - elsif ($row[0] eq 'idVendor' && $row[2]){ - $vendor = main::cleaner($row[2]); - } - elsif ($row[0] eq 'idProduct' && $row[2]){ - $product = main::cleaner($row[2]); - } - # we want hubs to cascade to last item - elsif ($row[0] eq '~bInterfaceClass' && $row[2] && defined $row[1] && $row[1] != 9){ - $class = main::cleaner($row[2]); - } - elsif ($row[0] eq '~bInterfaceProtocol' && defined $row[2]){ - $protocol = $row[2]; - $protocol =~ s/none//i if $protocol; - last if $class; - } + $type = $id[14] if $id[14]; + $driver = $id[15] if $id[15]; + $type ||= 'N/A'; + $driver ||= 'N/A'; + #print "pt3:$class:$product\n"; + $rows[$j]{main::key($num++,'Device')} = $product; + if ($extra > 1){ + $rows[$j]{main::key($num++,'driver')} = $driver; } - if ( $b_hub ){ - if ($vendor && $product){ - $protocol = "$vendor $product"; - } - elsif (!$product && $protocol && $vendor){ - $protocol = "$vendor $protocol"; - } - $speed ||= 'N/A'; - $protocol ||= 'N/A'; - #print "pt2:$protocol\n"; - @data = ({ - main::key($num++,'Hub') => $bus_id, - main::key($num++,'usb') => $speed, - main::key($num++,'type') => $protocol, - },); - @rows = (@rows,@data); + if ($extra > 0){ + $rows[$j]{main::key($num++,'usb')} = $speed; } - else { - if ($vendor && $product){ - if ($product !~ /$vendor/){ - $product = "$vendor $product"; - } - } - elsif (!$product && !$vendor && $protocol){ - $product = $protocol; - } - elsif (!$product){ - $product = $vendor; - } - # bInterfaceProtocol:0 but $row[2] undefined - #print "pt3:$class:$product\n"; - # for we want Mass Storage Device instead of Bulk-Only - # we want to filter out certain protocol values that are less - # informative than the class type. - if ($protocol && $class && $class ne $protocol && protocol_filter($protocol) ){ - $class = $protocol; - } - $class ||= 'N/A'; - #print "pt3:$class:$product\n"; - $product ||= 'N/A'; - $speed ||= 'N/A'; - $rows[$j]{main::key($num++,'Device')} = $product; - $rows[$j]{main::key($num++,'bus ID')} = $bus_id; - if ($extra > 0){ - $rows[$j]{main::key($num++,'usb')} = $speed; - } - $rows[$j]{main::key($num++,'type')} = $class; + $rows[$j]{main::key($num++,'type')} = $type; + $rows[$j]{main::key($num++,'bus ID')} = $bus_id; + } + if ($extra > 1){ + $rows[$j]{main::key($num++,'chip ID')} = $chip_id; + } + if (!$b_hub && $extra > 2){ + if ($id[9]){ + $rows[$j]{main::key($num++,'interfaces')} = $id[9]; } - if ($extra > 1){ - $rows[$j]{main::key($num++,'chip ID')} = $chip_id; + if ($serial){ + $rows[$j]{main::key($num++,'serial')} = main::apply_filter($serial); } } } @@ -14613,13 +14699,6 @@ sub usb_data { eval $end if $b_log; return @rows; } -sub protocol_filter { - eval $start if $b_log; - my ($string) = @_; - $string =~ s/Bulk-Only|streaming|Bidirectional|None//i if $string; - eval $end if $b_log; - return $string; -} } ## add metric / imperial (us) switch @@ -15319,10 +15398,11 @@ sub get_env_de_data { # note, X-Cinnamon value strikes me as highly likely to change, so just # search for the last part [0,'cinnamon','cinnamon','cinnamon',0,0], - # these two so far have no cli version data + # these so far have no cli version data + [1,'deepin','deepin','dde-desktop',0,1], # version comes from file read [1,'pantheon','pantheon','pantheon',0,0], [1,'lumina','lumina','lumina-desktop',0,1], - [1,'deepin','deepin','dde-desktop',0,1], + [0,'manokwari','manokwari','manokwari',1,0], ); foreach my $ref (@desktops){ my @item = @$ref; @@ -15352,25 +15432,28 @@ sub get_env_xprop_de_data { # but it will still trigger the next gnome true case, so this needs to go # before gnome test eventually this needs to be better organized so all the # xprop tests are in the same section, but this is good enough for now. - # NOTE: was checking for 'muffinr' but that's not part of cinnom + # NOTE: was checking for 'muffin' but that's not part of cinnamon if ( (main::check_program('muffin') || main::check_program('cinnamon-session') ) && ($b_xprop && main::awk(\@xprop,'_muffin') )){ - @data = main::program_values('cinnamon'); - $desktop[0] = $data[3]; - $desktop[1] = main::program_version('cinnamon',$data[0],$data[1],$data[2],$data[5],$data[6]); + @data = main::program_data('cinnamon','cinnamon',0); + $desktop[0] = $data[0]; + $desktop[1] = $data[1]; # $b_gtk = 1; $desktop[0] ||= 'Cinnamon'; } elsif ($xdg_desktop eq 'mate' || ( $b_xprop && main::awk(\@xprop,'_marco') )){ - # NOTE: mate-about reported wrong version, 1.18.0 when actual was 1.18.2 - if ($program = main::check_program('mate-session') ) { - $value = 'mate-session'; - } - if ($value){ - @data = main::program_values($value); - $desktop[0] = $data[3]; - $desktop[1] = main::program_version($program,$data[0],$data[1],$data[2],$data[5],$data[6]); - } + # NOTE: mate-about and mate-sesssion vary which has the higher number, neither + # consistently corresponds to the actual MATE version, so check both. + my %versions = ('mate-about' => '','mate-session' => ''); + foreach my $key (keys %versions){ + if ($program = main::check_program($key) ) { + @data = main::program_data($key,$program,0); + $desktop[0] = $data[0]; + $versions{$key} = $data[1]; + } + } + # no consistent rule about which version is higher, so just compare them and take highest + $desktop[1] = main::compare_versions($versions{'mate-about'},$versions{'mate-session'}); # $b_gtk = 1; $desktop[0] ||= 'MATE'; } @@ -15437,13 +15520,20 @@ sub get_xprop_de_data { $desktop[2] = $data[3]; } } - elsif (main::check_program('enlightenment') && main::awk(\@xprop,'enlightenment' )){ - $desktop[0] = 'Enlightenment'; + elsif ( (main::check_program('enlightenment') || main::check_program('moksha') ) && + main::awk(\@xprop,'moksha') ){ + # no -v or --version but version is in xprop -root + # ENLIGHTENMENT_VERSION(STRING) = "Moksha 0.2.0.15989" + $desktop[0] = 'Moksha'; + $desktop[1] = main::awk(\@xprop,'(enlightenment|moksha)_version',2,'\s+=\s+' ); + $desktop[1] =~ s/"?(Moksha|Enlightenment)\s([^"]+)"?/$2/i if $desktop[1]; + } + elsif ( main::check_program('enlightenment') && main::awk(\@xprop,'enlightenment' ) ){ # no -v or --version but version is in xprop -root # ENLIGHTENMENT_VERSION(STRING) = "Enlightenment 0.16.999.49898" - $desktop[1] = main::awk(\@xprop,'enlightenment_version',2,'\s+=\s+' ); - $desktop[1] = (split /"/, $desktop[1])[1] if $desktop[1]; - $desktop[1] = (split /\s+/, $desktop[1])[1] if $desktop[1]; + $desktop[0] = 'Enlightenment'; + $desktop[1] = main::awk(\@xprop,'(enlightenment|moksha)_version',2,'\s+=\s+' ); + $desktop[1] =~ s/"?(Moksha|Enlightenment)\s([^"]+)"?/$2/i if $desktop[1]; } # the sequence here matters, some desktops like icewm, razor, let you set different # wm, so we want to get the main controlling desktop first, then fall back to the wm @@ -15468,11 +15558,9 @@ sub get_xprop_de_data { my @item = @$ref; if (main::check_program($item[0]) && main::awk(\@xprop,$item[1]) && (!$item[4] || (@ps_gui && (grep {/$item[4]/} @ps_gui ))) ){ - @data = main::program_values($item[2]); - $desktop[0] = $data[3]; - if ($data[1] && $data[2]){ - $desktop[1] = main::program_version($item[3],$data[0],$data[1],$data[2],$data[5],$data[6]); - } + @data = main::program_data($item[2],$item[3],0); + $desktop[0] = $data[0]; + $desktop[1] = $data[1]; last; } } @@ -15506,18 +15594,28 @@ sub get_ps_de_data { ['wmii','wmii','wmii','wmii'], ['9wm','9wm','9wm','9wm'], ['amiwm','amiwm','amiwm','amiwm'], + ['fireplace','fireplace','fireplace','fireplace'], ['flwm','flwm','flwm','flwm'], + ['flwm','flwm_topside','flwm','flwm'], + ['ion','ion','ion','ion'], ['jwm','jwm','jwm','jwm'], + ['lwm','lwm','lwm','lwm'], ['mwm','mwm','mwm','mwm'], + ['nawm','nawm','nawm','nawm'], ['notion','notion','notion','notion'], + ['orbital','orbital','orbital','orbital'], + ['perceptia','perceptia','perceptia','perceptia'], + ['qtile','qtile','qtile','qtile'], ['ratpoison','ratpoison','ratpoison','ratpoison'], ['sawfish','sawfish','sawfish','sawfish'], ['matchbox-window-manager','matchbox-window-manager', 'matchbox-window-manager','matchbox-window-manager'], ['afterstep','afterstep','afterstep','afterstep'], ['bspwm','bspwm','bspwm','bspwm'], + ['tvtwm','tvtwm','tvtwm','tvtwm'], ['WindowMaker','WindowMaker','wmaker','wmaker'], ['windowlab','windowlab','windowlab','windowlab'], + ['wmx','wmx','wmx','wmx'], ['xmonad','xmonad','xmonad','xmonad'], ); foreach my $ref (@desktops){ @@ -15525,11 +15623,9 @@ sub get_ps_de_data { # no need to use check program with short list of ps_gui # if ( main::check_program($item[0]) && (grep {/^$item[1]$/} @ps_gui)){ if (grep {/^$item[1]$/} @ps_gui){ - @data = main::program_values($item[2]); - $desktop[0] = $data[3]; - if ($data[1] && $data[2]){ - $desktop[1] = main::program_version($item[3],$data[0],$data[1],$data[2],$data[5],$data[6]); - } + @data = main::program_data($item[2],$item[3],0); + $desktop[0] = $data[0]; + $desktop[1] = $data[1]; last; } } @@ -15605,11 +15701,11 @@ sub get_wm_main { main::set_ps_gui() if ! $b_ps_gui; # order matters, see above logic $wms = '9wm|afterstep|amiwm|awesome|bspwm|budgie-wm|compiz|fluxbox|blackbox|'; - $wms .= 'deepin-wm|dwm|flwm|fvwm-crystal|fvwm2|fvwm|gala|gnome-shell|i3|jwm|'; - $wms .= 'twin|kwin_wayland|kwin_x11|kwin|matchbox-window-manager|marco|'; + $wms .= 'deepin-wm|dwm|fireplace|flwm|fvwm-crystal|fvwm2|fvwm|gala|gnome-shell|i3|ion|jwm|'; + $wms .= 'twin|kwin_wayland|kwin_x11|kwin|lwm|matchbox-window-manager|marco|'; $wms .= 'muffin|deepin-mutter|mutter|deepin-metacity|metacity|mwm|'; - $wms .= 'notion|openbox|ratpoison|sawfish|scrotwm|spectrwm|'; - $wms .= 'twm|windowlab|WindowMaker|wm2|wmii2|wmii|xfwm4|xfwm5|xmonad'; + $wms .= 'nawm|notion|openbox|orbital|perceptia|qtile|ratpoison|sawfish|scrotwm|spectrwm|'; + $wms .= 'tvtwm|twm|windowlab|WindowMaker|wm2|wmii2|wmii|wmx|xfwm4|xfwm5|xmonad'; foreach (@ps_gui){ if (/^($wms)$/){ $working = $1; @@ -15654,15 +15750,11 @@ sub get_wm_version { $temp = (split /\s+/, $temp)[0]; $temp = lc($temp); $temp = 'wmaker' if $temp eq 'windowmaker'; - my @data = main::program_values($temp); - return if !@data; + my @data = main::program_data($temp,$temp,3); + return if !$data[0]; # print Data::Dumper::Dumper \@data; - $desktop[5] = $data[3] if $type eq 'manual'; - # note: if values returns 0 for 1 and 2, it doesn't support versioning - if ($extra > 2 && $data[1] && $data[2]){ - my $version = main::program_version($temp,$data[0],$data[1],$data[2],$data[5],$data[6]); - $desktop[6] = $version if $version; - } + $desktop[5] = $data[0] if $type eq 'manual'; + $desktop[6] = $data[1] if $data[1]; } eval $end if $b_log; } @@ -15672,12 +15764,13 @@ sub get_wm_version { sub set_info_data { eval $start if $b_log; my (@data,@info,$item); - my $pattern = 'awn|bar|bmpanel|bmpanel2|budgie-panel|cairo-dock|'; - $pattern .= 'dde-dock|dmenu|dockbarx|docky|dzen|dzen2|'; - $pattern .= 'fbpanel|fspanel|gnome-panel|hpanel|i3bar|icewmtray|kicker|'; - $pattern .= 'lemonbar|ltpanel|lxpanel|lxqt-panel|matchbox-panel|'; - $pattern .= 'mate-panel|plank|plasma-desktop|plasma-netbook|polybar|pypanel|'; - $pattern .= 'razor-panel|razorqt-panel|tint2|'; + my $pattern = 'alltray|awn|bar|bmpanel|bmpanel2|budgie-panel|cairo-dock|'; + $pattern .= 'dde-dock|dmenu|dockbarx|docker|docky|dzen|dzen2|'; + $pattern .= 'fbpanel|fspanel|glx-dock|gnome-panel|hpanel|i3bar|icewmtray|'; + $pattern .= 'kdocker|kicker|'; + $pattern .= 'latte|lemonbar|ltpanel|lxpanel|lxqt-panel|matchbox-panel|mate-panel|'; + $pattern .= 'ourico|perlpanel|plank|plasma-desktop|plasma-netbook|polybar|pypanel|'; + $pattern .= 'razor-panel|razorqt-panel|stalonetray|taskbar|tint2|trayer|'; $pattern .= 'vala-panel|wbar|wharf|wingpanel|witray|'; $pattern .= 'xfce4-panel|xfce5-panel|xmobar|yabar'; if (@data = grep {/^($pattern)$/} @ps_gui ) { @@ -15690,7 +15783,10 @@ sub set_info_data { } } } - $desktop[4] = join (', ', @info) if @info; + if (@info){ + @info = main::uniq(@info); + $desktop[4] = join (', ', @info); + } eval $end if $b_log; } @@ -15702,7 +15798,7 @@ sub set_xprop { # add wm / de as required, but only add what is really tested for above # XFDESKTOP_IMAGE_FILE; XFCE_DESKTOP my $pattern = '^amiwm|blackbox_pid|bspwm|compiz|enlightenment|^_gnome|'; - $pattern .= 'herbstluftwm|^kwin_|^i3_|icewm|_marco|^_motif|_muffin|'; + $pattern .= 'herbstluftwm|^kwin_|^i3_|icewm|_marco|moksha|^_motif|_muffin|'; $pattern .= 'openbox_pid|^_?windowmaker|^_wm2|^(xfdesktop|xfce)'; # let's only do these searches once @xprop = grep {/^\S/ && /($pattern)/i} @xprop; @@ -15718,13 +15814,13 @@ sub set_xprop { sub get_display_manager { eval $start if $b_log; - my (@data,@found,$temp,$working,$b_run,$b_vrun,$b_vrunrc); + my (@data,@found,$path,$working,$b_run,$b_vrun,$b_vrunrc); # ldm - LTSP display manager. Note that sddm does not appear to have a .pid # extension in Arch note: to avoid positives with directories, test for -f # explicitly, not -e my @dms = qw(entranced.pid gdm.pid gdm3.pid kdm.pid ldm.pid - lightdm.pid lxdm.pid mdm.pid nodm.pid pcdm.pid sddm.pid slim.lock - tint2.pid wdm.pid xdm.pid xenodm.pid); + lightdm.pid lxdm.pid mdm.pid nodm.pid pcdm.pid sddm.pid slim.lock + wdm.pid xdm.pid xenodm.pid); # these are the only one I know of so far that have version info my @dms_version = qw(gdm gdm3 lightdm slim); $b_run = 1 if -d "/run"; @@ -15747,11 +15843,12 @@ sub get_display_manager { ( $b_vrun && ( -f "/var/run/$id" || -d "/var/run/$working" ) ) || ( $b_vrunrc && ( -f "/var/run/rc.d/$working" || -d "/var/run/rc.d/$id" ) ) ) && ! grep {/$working/} @found ){ - if ($extra > 2 && awk( \@dms_version, $working) && (my $path = main::check_program($working)) ){ - @data = main::program_values($working); - $temp = main::program_version($path,$data[0],$data[1],$data[2],$data[5],$data[6]); - $working .= ' ' . $temp if $temp; - } + if ($extra > 2 && awk( \@dms_version, $working) && ($path = main::check_program($working)) ){} + else {$path = $working;} + # print "$path $extra\n"; + @data = main::program_data($working,$path,3); + $working = $data[0]; + $working .= ' ' . $data[1] if $data[1]; push @found, $working; } } @@ -15811,7 +15908,7 @@ sub get_linux_distro { my ($distro,$distro_id,$distro_file,$system_base) = ('','','',''); my ($b_issue,$b_osr,$b_use_issue,@working); # order matters! - my @derived = qw(antix-version aptosid-version kanotix-version knoppix-version + my @derived = qw(antix-version aptosid-version bodhibuilder.conf kanotix-version knoppix-version pclinuxos-release mandrake-release manjaro-release mx-version pardus-release porteus-version sabayon-release siduction-version sidux-version slitaz-release solusos-release turbolinux-release zenwalk-version); @@ -15828,6 +15925,7 @@ sub get_linux_distro { # wait to handle since crunchbang file is one of the few in the world that # uses this method my @distro_files = main::globber('/etc/*[-_]{[rR]elease,[vV]ersion,issue}*'); + push @distro_files, '/etc/bodhibuilder.conf' if -r '/etc/bodhibuilder.conf'; my $lsb_release = '/etc/lsb-release'; my $b_lsb = 1 if -f $lsb_release; my ($etc_issue,$issue,$lc_issue) = ('','/etc/issue',''); @@ -15925,6 +16023,11 @@ sub get_linux_distro { @working = main::reader($distro_file); $distro = main::awk(\@working,'suse'); } + elsif ($distro_file eq '/etc/bodhibuilder.conf'){ + @working = main::reader($distro_file); + $distro = main::awk(\@working,'^LIVECDLABEL',2,'\s*=\s*'); + $distro =~ s/"//g if $distro; + } else { $distro = (main::reader($distro_file))[0]; } @@ -15989,10 +16092,10 @@ sub get_linux_distro { if ($extra > 0){ my $base_default = 'antix-version|mx-version'; # osr has base ids my $base_issue = 'bunsen'; # base only found in issue - my $base_manual = 'kali'; # synthesize, no direct data available - my $base_osr = 'aptosid|grml|siduction'; # osr base, distro id in list of distro files + my $base_manual = 'blankon|deepin|kali'; # synthesize, no direct data available + my $base_osr = 'aptosid|grml|siduction|bodhi'; # osr base, distro id in list of distro files my $base_osr_issue = 'grml|linux lite'; # osr base, distro id in issue - my $base_osr_ubuntu = 'mint|zorin'; # osr has distro name but has ubuntu ID_LIKE/UBUNTU_CODENAME + my $base_osr_ubuntu = 'mint|neon|zorin'; # osr has distro name but has ubuntu ID_LIKE/UBUNTU_CODENAME my $base_upstream_lsb = '/etc/upstream-release/lsb-release'; my $base_upstream_osr = '/etc/upstream-release/os-release'; # first: try, some distros have upstream-release, elementary, new mint @@ -16035,12 +16138,24 @@ sub get_linux_distro { if (!$system_base && $lc_issue && $lc_issue =~ /($base_manual)/){ my $id = $1; my %manual = ( + 'blankon' => 'Debian unstable', + 'deepin' => 'Debian unstable', 'kali' => 'Debian testing', ); $system_base = $manual{$id}; } + if ($distro && -d '/etc/salixtools/' && $distro =~ /Slackware/i){ + $system_base = $distro; + } + } + if ($distro){ + if ($distro_id eq 'armbian'){ + $distro =~ s/Debian/Armbian/; + } + elsif (-d '/etc/salixtools/' && $distro =~ /Slackware/i){ + $distro =~ s/Slackware/Salix/; + } } - $distro =~ s/Debian/Armbian/ if ($distro && $distro_id eq 'armbian'); ## finally, if all else has failed, give up $distro ||= 'unknown'; @distro_data = ($distro,$system_base); @@ -16328,8 +16443,7 @@ sub get_init_data { $init = 'SysVinit'; if (check_program('strings')){ @data = grabber('strings /sbin/init'); - $init_version = awk(\@data,'version\s+[0-9]'); - $init_version = get_piece($init_version,2) if $init_version; + $init_version = awk(\@data,'^version\s+[0-9]',2); } } elsif ( -f '/etc/ttys' ){ @@ -16753,7 +16867,7 @@ sub get_start_parent { eval $start if $b_log; my ($parent) = @_; # ps -j -fp : bsds ps do not have -f for PPID, so we can't get the ppid - my $cmd = "ps -j -fp $parent"; + my $cmd = "ps -j -fp $parent 2>/dev/null"; log_data('cmd',$cmd) if $b_log; my @data = grabber($cmd); #shift @data if @data; @@ -16766,9 +16880,9 @@ sub get_start_parent { sub get_shell_parent { eval $start if $b_log; my ($parent) = @_; - my $cmd = "ps -j -p $parent"; + my $cmd = "ps -j -p $parent 2>/dev/null"; log_data('cmd',$cmd) if $b_log; - my @data = grabber($cmd,'strip'); + my @data = grabber($cmd,'','strip'); #shift @data if @data; my $shell_parent = awk(\@data, "$parent",-1,'\s+'); eval $end if $b_log; @@ -16860,82 +16974,6 @@ sub get_uptime { return $uptime; } -# NOTE: annoyingly, /sys does NOT actually use the id, it uses -# the count of physical devices, starting at 0 for hub, on the bus. -# args: $1 - $bus number; $2 - vendor:chip id -sub get_usb_drivers { - eval $start if $b_log; - my ($bus,$id) = @_; - return if !$bus || !$id;# these will be > 0 - my ($chip,$driver,$file,$path,$vendor,$working,$working2,@drivers,@temp); - @temp = split /:/, $id; - $vendor = $temp[0]; - $chip = $temp[1]; - # some have it one level deeper than others - my @globs = ("/sys/bus/usb/devices/usb$bus/$bus-*/","/sys/bus/usb/devices/usb$bus/$bus-*/$bus-*/"); - foreach (@globs){ - $path = get_usb_path($vendor,$chip,$_); - last if $path; - } - if ($path){ - if ( -e "${path}driver"){ - if ($working = Cwd::abs_path("${path}driver")){ - $working =~ s/^.*\///; - if ($working && $working ne 'usb' && $working ne 'usbhid'){ - push @drivers, $working; - } - } - } - # test 2 - @temp = main::globber("$path$bus-*/"); - #print "@temp\n"; - foreach (@temp){ - #print "p2:". $_ . "driver\n"; - $file = $_ . 'driver'; - #print "f:$file\n"; - if (-e $file){ - #print "here\n"; - #print (Cwd::abs_path($file), "\n"); - if ($working = Cwd::abs_path($file)){ - #print "w:$working\n"; - $working =~ s/^.*\///; - if ($working && $working ne 'usb' && $working ne 'usbhid' && ! grep {/$working/} @drivers){ - push @drivers, $working; - } - } - } - } - #print join "\n", @drivers, "\n"; - $driver = join ',', @drivers if @drivers; - } - @temp = ($driver,$path); - eval $end if $b_log; - return @temp; -} - -sub get_usb_path { - eval $start if $b_log; - my ($vendor,$chip,$glob) = @_; - my ($path,$working,$working2); - #print "$vendor,$chip,$glob\n"; - my @temp = main::globber($glob); - #print join "\n", @temp, "\n"; - # first we need to get the device path, since it's not predictable - foreach (@temp){ - #print "$_\n"; - $working = $_ . 'idVendor'; - $working2 = $_ . 'idProduct'; - if (-e $working && (main::reader($working))[0] eq $vendor && - -e $working2 && (main::reader($working2))[0] eq $chip){ - $path = $_; - #print "$_\n"; - last; - } - } - eval $end if $b_log; - return $path -} - #### ------------------------------------------------------------------- #### SET DATA VALUES #### ------------------------------------------------------------------- @@ -17246,7 +17284,7 @@ sub set_pci_data { # ! -d '/proc/bus/pci' # this is sketchy, a sbc won't have pci, but a non sbc arm may have it, so # build up both and see what happens - if ($b_arm || $b_mips){ + if ($b_arm || $b_mips || $b_ppc || $b_sparc){ set_soc_data(); } } @@ -17463,6 +17501,8 @@ sub set_pciconf_data { # /sys/devices/wlan.26/uevent [from pine64] ## 9 # sys/devices/platform/audio/uevent:["DRIVER=bcm2835_AUD0", "OF_NAME=audio" +## 10 +# /sys/devices/vio/71000002/uevent:["DRIVER=ibmveth", "OF_NAME=l-lan" sub set_soc_data { eval $start if $b_log; my ($content,@files,@temp2,@temp3,@working); @@ -17481,9 +17521,12 @@ sub set_soc_data { } @temp2 = globber('/sys/devices/*/uevent'); # see case 8 @files = (@files,@temp2) if @temp2; + @temp2 = globber('/sys/devices/*/*/uevent'); # see case 10 + @files = (@files,@temp2) if @temp2; @temp2 = undef; # not sure why, but even as root/sudo, /subsystem|driver/uevent are unreadable with -r test true @files = grep {!/\/(subsystem|driver)\//} @files if @files; + @files = uniq(@files); foreach my $file (@files){ next if -z $file; my ($busid,$busid_nu,$chip_id,$device,$driver,$modules,$port,$rev, @@ -17491,9 +17534,10 @@ sub set_soc_data { $chip_id = $file; # variants: /soc/20100000.ethernet /soc/soc:audio /soc:/ /soc@0/ # mips: /sys/devices/soc.0/1180000001800.mdio/8001180000001800:07/ - $chip_id =~ /\/sys\/devices\/(platform\/)?(soc[^\/]*\/)?([^\/]+\/)?([^\/]+\/)?([^\/]+)[\.:]([^\/]+)\/uevent$/; + # ppc: /sys/devices/vio/71000002/ + $chip_id =~ /\/sys\/devices\/(platform\/)?(soc[^\/]*\/)?([^\/]+\/)?([^\/]+\/)?([^\/\.:]+)([\.:])?([^\/]+)?\/uevent$/; $chip_id = $5; - $temp = $6; + $temp = $7; @working = reader($file, 'strip') if -r $file; foreach my $data (@working){ @temp2 = split /=/, $data; @@ -17512,6 +17556,8 @@ sub set_soc_data { } # it's worthless, we can't use it next if ! defined $type; + $chip_id = '' if ! defined $chip_id; + $vendor_id = '' if ! defined $vendor_id; $driver = '' if ! defined $driver; $busid = (defined $temp && is_int($temp)) ? $temp: 0; $busid_nu = 0; @@ -17522,7 +17568,7 @@ sub set_soc_data { # note: use these for main Card match for -AGN $b_soc_audio = 1 if $type =~ /^(audio|daudio|hdmi|hdmi-audio|multimedia)$/; $b_soc_gfx = 1 if $type =~ /^(vga|disp|display|display-port-controller|3d|fb|gpu|hdmi|mali)$/; - $b_soc_net = 1 if $type =~ /^(eth|ethernet|ethernet-phy|network|wifi|wlan)$/; + $b_soc_net = 1 if $type =~ /^(eth|ethernet|ethernet-phy|lan|l-lan|network|wifi|wlan)$/; @temp3 = ($type,$type_id,$busid,$busid_nu,$device,$vendor_id,$chip_id,$rev,$port,$driver,$modules); @pci = (@pci,[@temp3]); } @@ -17532,8 +17578,16 @@ sub set_soc_data { } sub set_ps_aux { eval $start if $b_log; - @ps_aux = split "\n",qx(ps aux);; - shift @ps_aux; # get rid of header row + @ps_aux = grabber("ps aux",'','strip'); + my $header = shift @ps_aux; # get rid of header row + # handle busy box, which has 3 columns, regular ps aux has 11 + # avoid deprecated implicit split error in older Perls + my @temp = split(/\s+/, $header); + $ps_cols = $#temp; + if ($ps_cols < 10){ + my $version = qx(ps --version 2>&1); + $b_bb_ps = 1 if $version =~/busybox/i; + } $_=lc for @ps_aux; # this is a super fast way to set to lower # note: regular perl /.../inxi but sudo /.../inxi is added for sudo start # for pinxi, we want to see the useage data for cpu/ram @@ -17544,8 +17598,8 @@ sub set_ps_aux { # slice out 10th to last elements of ps aux rows my $final = $#split; # some stuff has a lot of data, chrome for example - $final = ($final > 12) ? 12 : $final; - @split = @split[10 .. $final ]; + $final = ($final > ($ps_cols + 2) ) ? $ps_cols + 2 : $final; + @split = @split[$ps_cols .. $final]; join " ", @split; } @ps_aux; #@ps_cmd = grep {!/^\[/} @ps_cmd; @@ -17562,10 +17616,11 @@ sub set_ps_gui { @temp=qw(razor-desktop razor-session lxsession lxqt-session tdelauncher tdeinit_phase1); @match = (@match,@temp); - @temp=qw(3dwm 9wm afterstep amiwm afterstep awesome - blackbox bspwm dwm fluxbox flwm fvwm.*-crystal fvwm2 fvwm - i3 jwm matchbox-window-manager mwm openbox notion pekwm ratpoison sawfish - scrotwm spectrwm twm windowlab WindowMaker wm2 wmii2 wmii xmonad); + @temp=qw(3dwm 9wm afterstep amiwm awesome blackbox bspwm + dwm fluxbox flwm flwm_topside fvwm.*-crystal fvwm2 fvwm i3 ion jwm lwm + matchbox-window-manager mwm nawm openbox notion orbital pekwm perceptia + qtile ratpoison sawfish scrotwm spectrwm tvtwm twm + windowlab WindowMaker wm2 wmii2 wmii wmx xmonad); @match = (@match,@temp); } # wm: @@ -17573,26 +17628,28 @@ sub set_ps_gui { @temp=qw(budgie-wm compiz deepin-wm gala gnome-shell twin kwin_wayland kwin_x11 kwin marco deepin-metacity metacity metisse mir muffin deepin-mutter mutter - xfwm4 xfwm5 xmonad); + xfwm4 xfwm5); @match = (@match,@temp); } - # info: + # info: NOTE: glx-dock is cairo-dock if ($show{'system'} && $extra > 2){ - @temp=qw(awn bar bmpanel bmpanel2 budgie-panel cairo-dock - dde-dock dmenu dockbarx docky dzen dzen2 - fbpanel fspanel gnome-panel hpanel - i3bar icewmtray kicker lemonbar ltpanel lxpanel lxqt-panel - matchbox-panel mate-panel + @temp=qw(alltray awn bar bmpanel bmpanel2 budgie-panel + cairo-dock dde-dock dmenu dockbarx docker docky dzen dzen2 + fbpanel fspanel glx-dock gnome-panel hpanel i3bar icewmtray + kdocker kicker latte lemonbar ltpanel lxpanel lxqt-panel + matchbox-panel mate-panel ourico perlpanel plank plasma-desktop plasma-netbook polybar pypanel - razor-panel razorqt-panel tint2 vala-panel wbar wharf wingpanel witray - xfce4-panel xfce5-panel xmobar yabar); + razor-panel razorqt-panel stalonetray taskbar tint2 trayer vala-panel + wbar wharf wingpanel witray xfce4-panel xfce5-panel xmobar yabar); @match = (@match,@temp); } # compositors (for wayland these are also the server, note if ($show{'graphic'} && $extra > 1){ - @temp=qw(budgie-wm compiz compton dwc dcompmgr enlightenment - grefson ireplace kmscon kwin_wayland kwin_x11 metisse mir moblin - rustland sway swc unagi wayhouse westford weston xcompmgr); + @temp=qw(3dwm asc budgie-wm compiz compton deepin-wm dwc dcompmgr + enlightenment fireplace gnome-shell grefson kmscon kwin_wayland kwin_x11 + liri marco metisse mir moblin motorcar muffin mutter + orbital papyros perceptia rustland sommelier sway swc unagi + wavy way-cooler wayhouse westford weston xcompmgr); @match = (@match,@temp); } @match = uniq(@match); @@ -17651,19 +17708,34 @@ sub set_sysctl_data { eval $end if $b_log; } -# http://www.usb.org/developers/defined_class +## @usb array indexes +# 0 - bus id / sort id +# 1 - device id +# 2 - path_id +# 3 - path +# 4 - class id +# 5 - subclass id +# 6 - protocol id +# 7 - vendor:chip id +# 8 - usb version +# 9 - interfaces +# 10 - ports +# 11 - vendor +# 12 - product +# 13 - device-name +# 14 - type string +# 15 - driver +# 16 - serial +# 17 - configuration sub set_usb_data { eval $start if $b_log; $b_usb_check = 1; - if ($alerts{'lsusb'}{'action'} eq 'use' ){ - #$usb_level = 2; - # NOTE: we can't get reliable usb network device with short - if ($usb_level == 2){ - set_lsusb_data_long(); - } - else { - set_lsusb_data_short(); - } + # if user config sets USB_SYS you can override with --usb-tool + if ((!$b_usb_sys || $b_usb_tool) && $alerts{'lsusb'}{'action'} eq 'use' ){ + set_lsusb_data(); + } + elsif (-d '/sys/bus/usb/devices'){ + UsbSysData::set('main'); } elsif ( $alerts{'usbdevs'}{'action'} eq 'use'){ set_usbdevs_data(); @@ -17671,14 +17743,14 @@ sub set_usb_data { eval $end if $b_log; } -sub set_lsusb_data_short { +sub set_lsusb_data { eval $start if $b_log; - my ($content,@data); + my (@data,@temp,@working); + my ($addr_id,$bus_id,$chip_id,$name,$path_id); my $b_live = 1; if ($b_live){ my $path = check_program('lsusb'); - $content = qx($path 2>/dev/null) if $path; - @data = split /\n/, $content if $content; + @data = grabber("$path 2>/dev/null") if $path; } else { open my $fh, '<', "$ENV{'HOME'}/bin/scripts/inxi/data/lsusb/mdmarmer-lsusb.txt" or die $!; @@ -17686,102 +17758,41 @@ sub set_lsusb_data_short { } foreach (@data){ next if /^\s*$|^Couldn't/; # expensive second call: || /UNAVAIL/ - my @working = split /\s+/, $_; + @working = split /\s+/, $_; $working[3] =~ s/:$//; - my $id = int($working[3]); - if ($id > 1){ - my $bus = int($working[1]); - my $chip = $working[5]; - my @temp = @working[6..$#working]; - my $name = join ' ', @temp; - if ($name !~ /hub/i){ - @usb = (@usb,[$bus,$id,$chip,$name]); - } - } + $addr_id = int($working[3]); + $bus_id = int($working[1]); + $path_id = "$bus_id-$addr_id"; + $chip_id = $working[5]; + @temp = @working[6..$#working]; + $name = join ' ', @temp; + $name = $name; + #print "$name\n"; + $working[0] = $bus_id; + $working[1] = $addr_id; + $working[2] = $path_id; + $working[3] = ''; + $working[4] = 0; + $working[5] = ''; + $working[6] = ''; + $working[7] = $chip_id; + $working[8] = ''; + $working[9] = ''; + $working[10] = 0; + $working[11] = ''; + $working[12] = ''; + $working[13] = $name; + $working[14] = ''; + $working[15] = ''; + $working[16] = ''; + @ + usb = (@usb,[@working]); + #print join ("\n",@working),"\n\n=====\n"; } print Dumper \@usb if $test[6]; - main::log_data('dump','@usb: short',\@usb) if $b_log; - eval $end if $b_log; -} - -sub set_lsusb_data_long { - eval $start if $b_log; - my ($content,@data,@working,$bus_id,$device_id,$id,$b_skip); - my $j = 0; - my $b_live = 1; - if ($b_live){ - my $path = check_program('lsusb'); - $content = qx($path -v 2>/dev/null) if $path; - @data = split /\n/, $content if $content; - } - else { - my $file; - #$file = "$ENV{'HOME'}/bin/scripts/inxi/data/lsusb/mdmarmer-lsusb-v.txt"; - $file = "$ENV{'HOME'}/bin/scripts/inxi/data/lsusb/lsusb-v-dz64.txt"; - open my $fh, '<', $file or die $!; - chomp(@data = <$fh>); - } - foreach (@data){ - # we won't need all the lsusb data, so set it to skip - # after the last item we might want - # Couldn't open device, some information will be missing - next if /^\s*$|^Couldn't/; # expensive second call: || /UNAVAIL/ - if (!$b_skip && $bus_id && /^\s\s/){ - #if ($_ =~ /\bDescriptor\b:/){ - if ($_ =~ /^\s+([\S]+)\sDescriptor:/){ - #$_ =~ /^\s+([\S]+)\sDescriptor:/; - $_ = "Descriptor_$1"; - } - else { - $_ =~ s/^\s\s|[\s]+$//g; - $_ =~ s/^[\s]+/~/g; - #$_ =~ s/[\s]+$//g; - $_ =~ s/\sType/_Type/g; - $_ =~ s/^([\S]+)[\s]+(.*)//; - my $one = ($1) ? $1: ''; - my $two = ($2) ? $2: ''; - $_ = "$one:$two"; - $b_skip = 1 if $one eq '~bInterfaceProtocol'; - #$_ = cleaner($_); - if (/([\S]+):([0-9]+|0x[0-9a-f]+)\s(.*)/){ - $_ = "$1:$2:$3"; - #$b_skip = 1 if $1 eq '~bInterfaceProtocol'; - } - #print "$1\n"; - } - push @working, $_; - } - elsif (/^Bus\s([0-9]+)\sDevice\s([0-9]+):\sID\s(([0-9a-f]{4}):([0-9a-f]{4})).*/){ - #elsif (/^Bus\s/){ - #if (/^Bus\s([0-9]+)\sDevice\s([0-9]+):\sID\s(([0-9a-f]{4}):([0-9a-f]{4})).*/){ - $j = scalar @usb; - $bus_id = int($1); # trim off leading 0's - $device_id = int($2); - $id = $3; - $b_skip = 0; - # we don't need 32, system boot, or 127, end of table - if (@working){ - if ($working[0] != 32 && $working[0] != 127){ - $usb[$j] = ( - [@working], - ); - } - } - @working = ($bus_id,$device_id,$id); - #} - } - } - if (@working){ - $j = scalar @usb; - $usb[$j] = ( - [@working], - ); - } - # last by not least, sort it by dmi type, now we don't have to worry - # about random dmi type ordering in the data, which happens - @usb = sort { $a->[0] <=> $b->[0] || $a->[1] <=> $b->[1] } @usb; + UsbSysData::set('lsusb') if @usb; print Dumper \@usb if $test[6]; - main::log_data('dump','@usb: long',\@usb) if $b_log; + main::log_data('dump','@usb: plain',\@usb) if $b_log; eval $end if $b_log; } @@ -17791,13 +17802,12 @@ sub set_lsusb_data_long { # port 2 powered sub set_usbdevs_data { eval $start if $b_log; - my (@data,@working,$class,$bus_id,$addr_id,$id,$speed,$protocol); - my $j = 0; - my $ports = 0; + my (@data,@working,$addr_id,$class,$bus_id,$chip_id,$hub_id, + $path_id,$port,$port_value,$name,$speed); + my ($ports,$j,$k) = (0,0,0); if (!$b_fake_usbdevs){ my $program = check_program('usbdevs'); - my $content = qx($program -v 2>/dev/null); - @data = split /\n/, $content; + @data = grabber("$program -v 2>/dev/null"); } else { open my $fh, '<', "$ENV{'HOME'}/bin/scripts/inxi/data/lsusb/bsd-usbdevs-v-1.txt" or die $!; @@ -17805,45 +17815,75 @@ sub set_usbdevs_data { } foreach (@data){ if (/^Controller\s\/dev\/usb([0-9]+)/){ - $j = scalar @usb; - $ports = 0; + # $j = scalar @usb; + ($j,$ports) = (0,0); + $port_value = ''; $bus_id = $1; @working = (); } elsif (/^addr\s([0-9]+):\s([^,]+),[^,]+,[^,]+,\s?([^,]+)\(0x([0-9a-f]{4})\),\s?([^,]+)\s?\(0x([0-9a-f]{4})\)/){ $j = scalar @usb; + $k = $j; + $hub_id = $1; $addr_id = $1; - $speed = "bcdUSB:$2"; - $id = "$4:$6"; - $protocol="~bInterfaceProtocol:0:$5 $3"; + $speed = $2; + $chip_id = "$4:$6"; + $name="$5 $3"; #print "p1:$protocol\n"; - $class='bDeviceClass:9:Hub'; - @working = ($bus_id,$addr_id,$id,$speed,$class,$protocol); - if (@working){ - $usb[$j] = ( - [@working], - ); - } + $path_id = "$bus_id-$hub_id"; + $port_value = ''; + $working[0] = $bus_id; + $working[1] = $addr_id; + $working[2] = $path_id; + $working[3] = ''; + $working[4] = 9; + $working[5] = ''; + $working[6] = ''; + $working[7] = $chip_id; + $working[8] = $speed; + $working[9] = ''; + $working[10] = 0; + $working[13] = $name; + $working[14] = 'Hub'; + $working[15] = ''; + $working[16] = ''; + $usb[$j] = ([@working],); @working = (); } elsif (/^\s+port\s([0-9]+)\saddr\s([0-9]+):\s([^,]+),[^,]+,[^,]+,\s?([^,]+)\(0x([0-9a-f]{4})\),\s?([^,]+)\s?\(0x([0-9a-f]{4})\)/){ $j = scalar @usb; + $port = $1; $addr_id = "$2"; - $speed = "bcdUSB:$3"; - $id = "$5:$7"; - $protocol="~bInterfaceProtocol:0:$6 $4"; + $speed = "$3"; + $chip_id = "$5:$7"; + $name="$6 $4"; #print "p2:$protocol\n"; $ports++; - @working = ($bus_id,$addr_id,$id,$speed,$protocol); - if (@working){ - $usb[$j] = ( - [@working], - ); - } + $path_id = "$bus_id-$hub_id.$port"; + $working[0] = $bus_id; + $working[1] = $addr_id; + $working[2] = $path_id; + $working[3] = ''; + $working[4] = 1; + $working[5] = ''; + $working[6] = ''; + $working[7] = $chip_id; + $working[8] = $speed; + $working[9] = ''; + $working[10] = 0; + $working[11] = ''; + $working[12] = ''; + $working[13] = $name; + $working[14] = ''; + $working[15] = ''; + $working[16] = ''; + $usb[$j] = ([@working],); + ${$usb[$k]}[10] = $ports; @working = (); } elsif (/^\s+port\s([0-9]+)\spowered/){ $ports++; + ${$usb[$k]}[10] = $ports; } } if (@working){ @@ -17857,6 +17897,255 @@ sub set_usbdevs_data { eval $end if $b_log; } +## UsbSysData +{ +package UsbSysData; + +my ($b_hub,$class_id,$protocol_id,$source,$subclass_id,$type); + +sub set { + eval $start if $b_log; + ($source) = @_; + my (@drivers,@uevent,@usb_sys,@working); + my ($bus_id,$bus_id_alpha,$chip_id,$configuration,$device_id,$driver,$ids,$interfaces, + $name,$path,$path_id,$ports,$product,$serial,$usb_version,$vendor,$vendor_id,); + my $i = 0; + my @files = main::globber('/sys/bus/usb/devices/*'); + # we want to get rid of the hubs with x-0: syntax, those are hubs found in /usbx + @files = grep {!/\/[0-9]+-0:/} @files; + #print join "\n", @files; + foreach (@files){ + @uevent = main::reader("$_/uevent") if -r "$_/uevent"; + $ids = main::awk(\@uevent,'^(DEVNAME|DEVICE\b)',2,'='); + if ( $ids){ + @drivers = (); + ($b_hub,$class_id,$protocol_id,$subclass_id) = (0,0,0,0); + ($driver,$interfaces,$name,$ports,$product,$serial,$type, + $usb_version,$vendor) = ('','','','','','','','',''); + #print Cwd::abs_path($_),"\n"; + #print "f1: $_\n"; + $path_id = $_; + $path_id =~ s/^.*\///; + $path_id =~ s/^usb([0-9]+)/$1-0/; + # if DEVICE= then path = /proc/bus/usb/001/001 else: bus/usb/006/001 + $ids =~ s/^\///; + @working = split /\//, $ids; + shift @working if $working[0] eq 'proc'; + $bus_id = int($working[2]); + $bus_id_alpha = bus_id_alpha($path_id); + $device_id = int($working[3]); + $class_id = sys_item("$_/bDeviceClass"); + $class_id = hex($class_id) if $class_id; + @drivers = uevent_data("$_/[0-9]*/uevent"); + @drivers = (@drivers, uevent_data("$_/[0-9]*/*/uevent")) if !$b_hub; + $ports = sys_item("$_/maxchild") if $b_hub; + $driver = join ',', sort(main::uniq(@drivers)) if @drivers; + $interfaces = sys_item("$_/bNumInterfaces"); + $serial = sys_item("$_/serial"); + $usb_version = sys_item("$_/version"); + if ($source eq 'lsusb'){ + for ($i = 0; $i < scalar @usb; $i++){ + if (${$usb[$i]}[0] eq $bus_id && ${$usb[$i]}[1] == $device_id){ + #print $type,"\n"; + ${$usb[$i]}[0] = $bus_id_alpha; + ${$usb[$i]}[2] = $path_id; + ${$usb[$i]}[3] = $_; + ${$usb[$i]}[4] = $class_id; + ${$usb[$i]}[5] = $subclass_id; + ${$usb[$i]}[6] = $protocol_id; + ${$usb[$i]}[8] = $usb_version; + ${$usb[$i]}[9] = $interfaces; + ${$usb[$i]}[10] = $ports if $ports; + if ($type && $b_hub && (!${$usb[$i]}[13] || ${$usb[$i]}[13] =~ /^linux foundation/i )){ + ${$usb[$i]}[13] = "$type"; + } + ${$usb[$i]}[14] = $type if ($type && !$b_hub); + ${$usb[$i]}[15] = $driver if $driver; + ${$usb[$i]}[16] = $serial if $serial; + #print join("\n",@{$usb[$i]}),"\n\n";# if !$b_hub; + last; + } + } + } + else { + $chip_id = sys_item("$_/idProduct"); + $vendor_id = sys_item("$_/idVendor"); + # we don't want the device, it's probably a bad path in /sys/bus/usb/devices + next if !$vendor_id && !$chip_id; + $configuration = sys_item("$_/configuration"); + $product = sys_item("$_/product"); + $product = main::cleaner($product) if $product; + $vendor = sys_item("$_/manufacturer"); + $vendor = main::cleaner($vendor) if $vendor; + if (!$b_hub && ($product || $vendor )){ + if ($vendor && $product && $product !~ /$vendor/){ + $name = "$vendor $product"; + } + elsif ($product){ + $name = $product; + } + elsif ($vendor){ + $name = $vendor; + } + } + elsif ($b_hub){ + $name = $type; + } + # this isn't that useful, but save in case something shows up + #if ($configuration){ + # $name = ($name) ? "$name $configuration" : $configuration; + #} + $type = 'Hub' if $b_hub; + ${$usb[$i]}[0] = $bus_id_alpha; + ${$usb[$i]}[1] = $device_id; + ${$usb[$i]}[2] = $path_id; + ${$usb[$i]}[3] = $_; + ${$usb[$i]}[4] = $class_id; + ${$usb[$i]}[5] = $subclass_id; + ${$usb[$i]}[6] = $protocol_id; + ${$usb[$i]}[7] = "$vendor_id:$chip_id"; + ${$usb[$i]}[8] = $usb_version; + ${$usb[$i]}[9] = $interfaces; + ${$usb[$i]}[10] = $ports; + ${$usb[$i]}[11] = $vendor; + ${$usb[$i]}[12] = $product; + ${$usb[$i]}[13] = $name; + ${$usb[$i]}[14] = $type; + ${$usb[$i]}[15] = $driver; + ${$usb[$i]}[16] = $serial; + ${$usb[$i]}[17] = $configuration; + $i++; + } + #print "$path_id ids: $bus_id:$device_id driver: $driver ports: $ports\n==========\n"; # if $test[6];; + } + } + @usb = sort { $a->[0] cmp $b->[0] } @usb; + print Data::Dumper::Dumper \@usb if $source eq 'main' && $test[6]; + main::log_data('dump','@usb: sys',\@usb) if $source eq 'main' && $b_log; + eval $end if $b_log; +} +# get driver, interface [type:] data +sub uevent_data { + my ($path) = @_; + my ($driver,$interface,$temp,@interfaces,@drivers,@working); + my @files = main::globber($path); + @files = grep {!/\/(subsystem|driver|ep_[^\/]+)\/uevent$/} @files if @files; + foreach (@files){ + last if $b_hub; + # print "f2: $_\n"; + ($interface) = (''); + @working = main::reader($_) if -r $_; + #print join ("\n",@working), "\n"; + if (@working){ + $driver = main::awk(\@working,'^DRIVER',2,'='); + $interface = main::awk(\@working,'^INTERFACE',2,'='); + if ($interface){ + $interface = device_type($interface); + if ($interface){ + if ($interface ne ''){ + push @interfaces, $interface; + } + # networking requires more data but this test is reliable + elsif (!@interfaces) { + $temp = $_; + $temp =~ s/\/uevent$//; + push @interfaces, 'Network' if -d "$temp/net/"; + } + if (!@interfaces){ + push @interfaces, $interface; + } + } + } + } + #print "driver:$driver\n"; + $b_hub = 1 if $driver && $driver eq 'hub'; + $driver = '' if $driver && ($driver eq 'usb' || $driver eq 'hub'); + push @drivers,$driver if $driver; + } + if (@interfaces){ + @interfaces = main::uniq(@interfaces); + # clear out values like: ,Printer + if ( scalar @interfaces > 1 && (grep {/^';} + + if ($types[0] eq '1'){$type = 'Audio';} + elsif ($types[0] eq '2'){ + if ($types[1] eq '2'){$type = 'Abstract (modem)';} + elsif ($types[1] eq '6'){$type = 'Ethernet Network';} + elsif ($types[1] eq '10'){$type = 'Mobile Direct Line';} + elsif ($types[1] eq '12'){$type = 'Ethernet Emulation';} + else {$type = 'Communication';} + } + elsif ($types[0] eq '3'){ + if ($types[2] eq '0'){$type = 'HID';} # actual value: None + elsif ($types[2] eq '1'){$type = 'Keyboard';} + elsif ($types[2] eq '2'){$type = 'Mouse';} + } + elsif ($types[0] eq '6'){$type = 'Still Imaging';} + elsif ($types[0] eq '7'){$type = 'Printer';} + elsif ($types[0] eq '8'){$type = 'Mass Storage';} + elsif ($types[0] eq '9'){ + if ($types[2] eq '0'){$type = 'Full speed (or root) Hub';} + elsif ($types[2] eq '1'){$type = 'Hi-speed hub with single TT';} + elsif ($types[2] eq '2'){$type = 'Hi-speed hub with multiple TTs';} + } + elsif ($types[0] eq '10'){$type = 'CDC-Data';} + elsif ($types[0] eq '11'){$type = 'Smart Card';} + elsif ($types[0] eq '13'){$type = 'Content Security';} + elsif ($types[0] eq '14'){$type = 'Video';} + elsif ($types[0] eq '15'){$type = 'Personal Healthcare';} + elsif ($types[0] eq '16'){$type = 'Audio-Video';} + elsif ($types[0] eq '17'){$type = 'Billboard';} + elsif ($types[0] eq '18'){$type = 'Type-C Bridge';} + elsif ($types[0] eq '88'){$type = 'Xbox';} + elsif ($types[0] eq '220'){$type = 'Diagnostic';} + elsif ($types[0] eq '224'){ + if ($types[1] eq '1'){$type = 'Bluetooth';} + elsif ($types[1] eq '2'){ + if ($types[2] eq '1'){$type = 'Host Wire Adapter';} + elsif ($types[2] eq '2'){$type = 'Device Wire Adapter';} + elsif ($types[2] eq '3'){$type = 'Device Wire Adapter';} + } + } + + return $type; +} +# this is used to create an alpha sortable bus id for main $usb[0] +sub bus_id_alpha { + my ($id) = @_; + $id =~ s/^([1-9])-/0$1-/; + $id =~ s/([-\.:])([0-9])\b/${1}0$2/g; + return $id; +} +} + ######################################################################## #### GENERATE LINES ######################################################################## @@ -18297,7 +18586,7 @@ sub generate_system_data { } # don't print the desktop if it's a wm and the same if ($extra > 1 && $desktop_data[5] && - (!$desktop_data[0] || $desktop_data[5] =~ /^(deepin-.*|gnome[\s\-_]shell|budgie-.*)$/i || + (!$desktop_data[0] || $desktop_data[5] =~ /^(deepin.+|gnome[\s\-_]shell|budgie.+)$/i || index(lc($desktop_data[5]),lc($desktop_data[0])) == -1 )){ $wm = $desktop_data[5]; $wm .= ' ' . $desktop_data[6] if $extra > 2 && $desktop_data[6]; -- cgit v1.2.3