New version, man page. Finished up main man edits. Set new defaults for some options,

like --sleep and -t.

Edits to layout and language, removed some legacy options and language from man and
inxi.

Added partition table detections, rough initial stage. Only works on systems with
udev present currently, will be expanded as we find fast tools. Since the systemd
method is literally up to 25x slower than the udev method, it's not being considered
except maybe as a last, last resort, and probably will never be used.
This commit is contained in:
Harald Hope 2018-04-06 15:52:08 -07:00
parent 35d5acfcae
commit e43933452f
3 changed files with 600 additions and 557 deletions

451
inxi
View file

@ -1,5 +1,5 @@
#!/usr/bin/env perl
## infobash: Copyright (C) 2005-2007 Michiel de Boer a.k.a. locsmif
## infobash: Copyright (C) 2005-2007 Michiel de Boer aka locsmif
## inxi: Copyright (C) 2008-2018 Harald Hope
## Additional features (C) Scott Rogers - kde, cpu info
## Further fixes (listed as known): Horst Tritremmel <hjt at sidux.com>
@ -22,7 +22,7 @@ use 5.008;
use Cwd qw(abs_path); # qw(abs_path);#abs_path realpath getcwd
# use Data::Dump qw(dump); # damn, not in core modules
use Data::Dumper qw(Dumper); # print_r
use File::Basename;
# use File::Basename;
use File::Find;
# use Getopt::Long qw(GetOptionsFromArray); # :config no_ignore_case bundling_values
use Getopt::Long qw(GetOptions);
@ -36,8 +36,8 @@ use POSIX qw(uname strftime ttyname);
## INXI INFO ##
my $self_name='inxi';
my $self_version='2.9.11';
my $self_date='2018-04-03';
my $self_version='2.9.12';
my $self_date='2018-04-06';
my $self_patch='00';
## END INXI INFO ##
@ -696,93 +696,6 @@ sub set_colors {
eval $end if $b_log;
}
#### -------------------------------------------------------------------
#### CONFIGS
#### -------------------------------------------------------------------
sub check_config_file {
$user_config_file = "$user_config_dir/$self_name.conf";
if ( ! -f $user_config_file ){
open( my $fh, '>', $user_config_file ) or error_handler('create', $user_config_file, $!);
}
}
sub get_configs {
my (@configs) = @_;
my ($key, $val,@config_files);
if (!@configs){
@config_files = (
qq(/etc/$self_name.conf),
qq($user_config_dir/$self_name.conf)
);
}
else {
@config_files = (@configs);
}
# Config files should be passed in an array as a param to this function.
# Default intended use: global @CONFIGS;
foreach (@config_files) {
next unless open (my $fh, '<', "$_");
while (<$fh>) {
chomp;
s/#.*//;
s/^\s+//;
s/\s+$//;
s/'|"//g;
s/true/1/; # switch to 1/0 perl boolean
s/false/0/; # switch to 1/0 perl boolean
next unless length;
($key, $val) = split(/\s*=\s*/, $_, 2);
get_config_item($key,$val);
# print "f: $file key: $key val: $val\n";
}
close $fh;
}
}
# args: 0: key; 1: value
sub get_config_item {
my ($key,$val) = @_;
if ($key eq 'ALLOW_UPDATE' || $key eq 'B_ALLOW_UPDATE') {$b_update = int($val)}
elsif ($key eq 'ALLOW_WEATHER' || $key eq 'B_ALLOW_WEATHER') {$b_weather = int($val)}
elsif ($key eq 'CPU_SLEEP') {$cpu_sleep = $val if $val =~ /^[0-9\.]$/}
elsif ($key eq 'DL_TIMEOUT') {$dl_timeout = int($val)}
elsif ($key eq 'DOWNLOADER') {
if ($val =~ /^(curl|fetch|ftp|perl|wget)$/){
# this dumps all the other data and resets %dl for only the
# desired downloader.
$val = set_perl_downloader($val);
%dl = ('dl' => $val, $val => 1);
}}
elsif ($key eq 'FILTER_STRING') {$filter_string = $val}
elsif ($key eq 'LANGUAGE') {$language = $val if $val =~ /^(en)$/}
elsif ($key eq 'LIMIT') {$limit = int($val)}
elsif ($key eq 'OUTPUT_TYPE') {$output_type = $val if $val =~ /^json|screen|xml/}
elsif ($key eq 'PS_COUNT') {$ps_count = int($val) }
elsif ($key eq 'SENSORS_CPU_NO') {$sensors_cpu_nu = int($val)}
elsif ($key eq 'SHOW_HOST' || $key eq 'B_SHOW_HOST') { $show{'host'} = int($val)}
# layout
elsif ($key eq 'CONSOLE_COLOR_SCHEME') {$colors{'console'} = int($val)}
elsif ($key eq 'GLOBAL_COLOR_SCHEME') {$colors{'global'} = int($val)}
elsif ($key eq 'IRC_COLOR_SCHEME') {$colors{'irc-gui'} = int($val)}
elsif ($key eq 'IRC_CONS_COLOR_SCHEME') {$colors{'irc-console'} = int($val)}
elsif ($key eq 'IRC_X_TERM_COLOR_SCHEME') {$colors{'irc-virt-term'} = int($val)}
elsif ($key eq 'VIRT_TERM_COLOR_SCHEME') {$colors{'virt-term'} = int($val)}
# note: not using the old short SEP1/SEP2
elsif ($key eq 'SEP1_IRC') {$sep{'s1-irc'} = $val}
elsif ($key eq 'SEP1_CONSOLE') {$sep{'s1-console'} = $val}
elsif ($key eq 'SEP[23]_IRC') {$sep{'s2-irc'} = $val}
elsif ($key eq 'SEP[23]_CONSOLE') {$sep{'s2-console'} = $val}
# size
elsif ($key eq 'COLS_MAX_CONSOLE') {$size{'console'} = int($val)}
elsif ($key eq 'COLS_MAX_IRC') {$size{'irc'} = int($val)}
elsif ($key eq 'COLS_MAX_NO_DISPLAY') {$size{'no-display'} = int($val)}
elsif ($key eq 'INDENT') {$size{'indent'} = int($val)}
elsif ($key eq 'INDENT_MIN') {$size{'indent-min'} = int($val)}
# print "mc: key: $key val: $val\n";
# print Dumper (keys %size) . "\n";
}
## SelectColors
{
package SelectColors;
@ -822,12 +735,12 @@ sub select_schema {
}
sub set_status {
$status{'console'} = (defined $colors{'console'}) ? "Set: $colors{'console'}" : 'Unset';
$status{'virt-term'} = (defined $colors{'virt-term'}) ? "Set: $colors{'virt-term'}" : 'Unset';
$status{'irc-console'} = (defined $colors{'irc-console'}) ? "Set: $colors{'irc-console'}" : 'Unset';
$status{'irc-gui'} = (defined $colors{'irc-gui'}) ? "Set: $colors{'irc-gui'}" : 'Unset';
$status{'irc-virt-term'} = (defined $colors{'irc-virt-term'}) ? "Set: $colors{'irc-virt-term'}" : 'Unset';
$status{'global'} = (defined $colors{'global'}) ? "Set: $colors{'global'}" : 'Unset';
$status{'console'} = (defined $colors{'console'}) ? "Set: $colors{'console'}" : 'Not Set';
$status{'virt-term'} = (defined $colors{'virt-term'}) ? "Set: $colors{'virt-term'}" : 'Not Set';
$status{'irc-console'} = (defined $colors{'irc-console'}) ? "Set: $colors{'irc-console'}" : 'Not Set';
$status{'irc-gui'} = (defined $colors{'irc-gui'}) ? "Set: $colors{'irc-gui'}" : 'Not Set';
$status{'irc-virt-term'} = (defined $colors{'irc-virt-term'}) ? "Set: $colors{'irc-virt-term'}" : 'Not Set';
$status{'global'} = (defined $colors{'global'}) ? "Set: $colors{'global'}" : 'Not Set';
}
sub assign_selectors {
@ -959,8 +872,10 @@ sub process_selection {
exit 1;
}
elsif ($response == ($count + 2)){
@data = ([0, '', '', "Ok, continuing $self_name unchanged. You can set the colors
anytime by starting with: -c 95 to 99"],);
@data = (
[0, '', '', "Ok, continuing $self_name unchanged."],
[0, '', '', "$line1"],
);
main::print_basic(@data);
if ( defined $colors{'console'} && !$b_display ){
main::set_color_scheme($colors{'console'});
@ -973,14 +888,20 @@ sub process_selection {
}
}
elsif ($response == ($count + 1)){
@data = ([0, '', '', "Removing all color settings from config file now..."],);
@data = (
[0, '', '', "Removing all color settings from config file now..."],
[0, '', '', "$line1"],
);
main::print_basic(@data);
delete_all_config_colors();
main::set_color_scheme($colors{'default'});
}
else {
main::set_color_scheme($response);
@data = ([0, '', '', "Updating config file for $configs{'selection'} color scheme now..."],);
@data = (
[0, '', '', "Updating config file for $configs{'selection'} color scheme now..."],
[0, '', '', "$line1"],
);
main::print_basic(@data);
if ($configs{'selection'} eq 'global'){
delete_all_config_colors();
@ -1035,6 +956,93 @@ sub print_irc_message {
}
#### -------------------------------------------------------------------
#### CONFIGS
#### -------------------------------------------------------------------
sub check_config_file {
$user_config_file = "$user_config_dir/$self_name.conf";
if ( ! -f $user_config_file ){
open( my $fh, '>', $user_config_file ) or error_handler('create', $user_config_file, $!);
}
}
sub get_configs {
my (@configs) = @_;
my ($key, $val,@config_files);
if (!@configs){
@config_files = (
qq(/etc/$self_name.conf),
qq($user_config_dir/$self_name.conf)
);
}
else {
@config_files = (@configs);
}
# Config files should be passed in an array as a param to this function.
# Default intended use: global @CONFIGS;
foreach (@config_files) {
next unless open (my $fh, '<', "$_");
while (<$fh>) {
chomp;
s/#.*//;
s/^\s+//;
s/\s+$//;
s/'|"//g;
s/true/1/; # switch to 1/0 perl boolean
s/false/0/; # switch to 1/0 perl boolean
next unless length;
($key, $val) = split(/\s*=\s*/, $_, 2);
get_config_item($key,$val);
# print "f: $file key: $key val: $val\n";
}
close $fh;
}
}
# args: 0: key; 1: value
sub get_config_item {
my ($key,$val) = @_;
if ($key eq 'ALLOW_UPDATE' || $key eq 'B_ALLOW_UPDATE') {$b_update = int($val)}
elsif ($key eq 'ALLOW_WEATHER' || $key eq 'B_ALLOW_WEATHER') {$b_weather = int($val)}
elsif ($key eq 'CPU_SLEEP') {$cpu_sleep = $val if $val =~ /^[0-9\.]$/}
elsif ($key eq 'DL_TIMEOUT') {$dl_timeout = int($val)}
elsif ($key eq 'DOWNLOADER') {
if ($val =~ /^(curl|fetch|ftp|perl|wget)$/){
# this dumps all the other data and resets %dl for only the
# desired downloader.
$val = set_perl_downloader($val);
%dl = ('dl' => $val, $val => 1);
}}
elsif ($key eq 'FILTER_STRING') {$filter_string = $val}
elsif ($key eq 'LANGUAGE') {$language = $val if $val =~ /^(en)$/}
elsif ($key eq 'LIMIT') {$limit = int($val)}
elsif ($key eq 'OUTPUT_TYPE') {$output_type = $val if $val =~ /^json|screen|xml/}
elsif ($key eq 'PS_COUNT') {$ps_count = int($val) }
elsif ($key eq 'SENSORS_CPU_NO') {$sensors_cpu_nu = int($val)}
elsif ($key eq 'SHOW_HOST' || $key eq 'B_SHOW_HOST') { $show{'host'} = int($val)}
# layout
elsif ($key eq 'CONSOLE_COLOR_SCHEME') {$colors{'console'} = int($val)}
elsif ($key eq 'GLOBAL_COLOR_SCHEME') {$colors{'global'} = int($val)}
elsif ($key eq 'IRC_COLOR_SCHEME') {$colors{'irc-gui'} = int($val)}
elsif ($key eq 'IRC_CONS_COLOR_SCHEME') {$colors{'irc-console'} = int($val)}
elsif ($key eq 'IRC_X_TERM_COLOR_SCHEME') {$colors{'irc-virt-term'} = int($val)}
elsif ($key eq 'VIRT_TERM_COLOR_SCHEME') {$colors{'virt-term'} = int($val)}
# note: not using the old short SEP1/SEP2
elsif ($key eq 'SEP1_IRC') {$sep{'s1-irc'} = $val}
elsif ($key eq 'SEP1_CONSOLE') {$sep{'s1-console'} = $val}
elsif ($key eq 'SEP[23]_IRC') {$sep{'s2-irc'} = $val}
elsif ($key eq 'SEP[23]_CONSOLE') {$sep{'s2-console'} = $val}
# size
elsif ($key eq 'COLS_MAX_CONSOLE') {$size{'console'} = int($val)}
elsif ($key eq 'COLS_MAX_IRC') {$size{'irc'} = int($val)}
elsif ($key eq 'COLS_MAX_NO_DISPLAY') {$size{'no-display'} = int($val)}
elsif ($key eq 'INDENT') {$size{'indent'} = int($val)}
elsif ($key eq 'INDENT_MIN') {$size{'indent-min'} = int($val)}
# print "mc: key: $key val: $val\n";
# print Dumper (keys %size) . "\n";
}
#### -------------------------------------------------------------------
#### DEBUGGERS
#### -------------------------------------------------------------------
@ -3344,15 +3352,15 @@ sub set_version_data {
}
########################################################################
#### OPTIONS HANDLER
#### OPTIONS HANDLER / VERSION
########################################################################
sub get_options{
eval $start if $b_log;
my (@args) = @_;
$show{'short'} = 1;
my ($b_downloader,$b_no_man,$b_no_man_force,$b_recommends,$b_updater,$b_version,
$b_use_man,$help_type,$self_download, $download_id);
my ($b_downloader,$b_help,$b_no_man,$b_no_man_force,$b_recommends,$b_updater,$b_version,
$b_use_man,$self_download, $download_id);
GetOptions (
'A|audio' => sub {
$show{'short'} = 0;
@ -3374,7 +3382,7 @@ sub get_options{
$show{'battery-forced'} = 1; },
'c|color:i' => sub {
my ($opt,$arg) = @_;
if ( $arg >= 0 && $arg <= get_color_scheme('count') ){
if ( $arg >= 0 && $arg < get_color_scheme('count') ){
set_color_scheme($arg);
}
elsif ( $arg >= 94 && $arg <= 99 ){
@ -3471,6 +3479,7 @@ sub get_options{
$show{'sensor'} = 1; },
'sleep:s' => sub {
my ($opt,$arg) = @_;
$arg ||= 0;
if ($arg >= 0){
$cpu_sleep = $arg;
}
@ -3486,6 +3495,7 @@ sub get_options{
't|processes|process:s' => sub {
my ($opt,$arg) = @_;
$show{'short'} = 0;
$arg ||= 'cm';
my $num = $arg;
$num =~ s/^[cm]+// if $num;
if ( $arg =~ /^([cm]+)([0-9]+)?$/ && (!$num || $num =~ /^\d+/) ){
@ -3613,6 +3623,7 @@ sub get_options{
} },
'y|width:i' => sub {
my ($opt, $arg) = @_;
$arg = 2000 if defined $arg && $arg == -1;
if ( $arg =~ /\d/ && $arg >= 80 ){
set_display_width($arg);
}
@ -3719,9 +3730,7 @@ sub get_options{
error_handler('bad-arg', $opt, $arg);
}},
'h|help|?' => sub {
$help_type = 'standard'; },
'H|help-full' => sub {
$help_type = 'full'; },
$b_help = 1; },
'host|hostname' => sub {
$show{'host'} = 1 },
'indent-min:i' => sub {
@ -3819,7 +3828,7 @@ sub get_options{
CheckRecommends::run() if $b_recommends;
set_downloader() if $b_downloader;
show_version() if $b_version;
show_options($help_type) if $help_type;
show_options() if $b_help;
$b_man = 0 if (!$b_use_man || $b_no_man_force);
update_me( $self_download, $download_id ) if $b_updater;
if ($output_type){
@ -3863,10 +3872,9 @@ sub get_options{
sub show_options {
error_handler('not-in-irc', 'help') if $b_irc;
my ($type) = @_;
my (@row,@rows,@data);
my $line = '';
my $color_scheme_count = get_color_scheme('count');
my $color_scheme_count = get_color_scheme('count') - 1;
my $partition_string='partition';
my $partition_string_u='Partition';
if ( $bsd_type ){
@ -3964,7 +3972,7 @@ sub show_options {
['1', '', '--slots', "Show PCI slots, type, speed, status. Requires root. " ],
['1', '-S', '--system', "System information: host name, kernel, desktop environment
(if in X), distro" ],
['1', '-t', '--processes', "Processes. Requires extra options: c^(cpu) m^(memory) cm^(cpu+memory).
['1', '-t', '--processes', "Processes. Default cm. Options: c^(cpu) m^(memory) cm^(cpu+memory).
If followed by numbers 1-X, shows that number of processes for each type
(default:^$ps_count; if in irc, max:^5): -t^cm10" ],
['1', '', '', "Make sure to have no space between letters and numbers
@ -4090,8 +4098,9 @@ sub show_options {
push @data, @rows;
}
@rows = (
['1', '-y', '--width', "Required extra option: integer, 80 or greater. Set the output
line width max. Overrides IRC/Terminal settings or actual widths. Example:^inxi^-y^130" ],
['1', '-y', '--width', "Required extra option: integer, 80 or greater (-1 removes width limit).
Set the output line width max. Overrides IRC/Terminal settings or actual widths.
Example:^inxi^-y^130" ],
['1', '-z', '--filter', "Security filters for IP/Mac addresses, location, user home
directory name. Default on for irc clients." ],
['1', '-Z', '--filter-override', "Absolute override for output filters. Useful for debugging
@ -4099,9 +4108,7 @@ sub show_options {
[0, '', '', "$line" ],
[0, '', '', "Additional Options:" ],
['1', '-h', '--help', "This help menu." ],
['1', '-H', '--help-full', "This help menu, plus developer options. Do not use dev options in
normal operation!" ],
['1', '', '--recommends', "Checks $self_name application dependencies + recommends,
['1', '', '--recommends', "Checks $self_name application dependencies + recommends,
and directories, then shows what package(s) you need to install to add support
for that feature. " ]
);
@ -4183,11 +4190,65 @@ sub show_options {
['0', '', '', $line ],
);
push @data, @rows;
if ( $type eq 'full' ){
print_basic(@data);
exit 1;
}
sub show_version {
require Cwd;
import Cwd;
# if not in PATH could be either . or directory name, no slash starting
my $working_path=$self_path;
my (@data, @row, @rows, $link, $self_string);
if ( $working_path eq '.' ){
$working_path = getcwd();
}
elsif ( $working_path !~ /^\// ){
$working_path = getcwd() . "/$working_path";
}
# handle if it's a symbolic link, rare, but can happen with directories
# in irc clients which would only matter if user starts inxi with -! 30 override
# in irc client
if ( -l "$working_path/$self_name" ){
$link="$working_path/$self_name";
$working_path = readlink "$working_path/$self_name";
$working_path =~ s/[^\/]+$//;
}
# strange output /./ ending, but just trim it off, I don't know how it happens
$working_path =~ s%/\./%/%;
@row = ([ 0, '', '', "$self_name $self_version-$self_patch ($self_date)"],);
push @data, @row;
if ( ! $b_irc ){
@row = ([ 0, '', '', ""],);
push @data, @row;
my $year = (split/-/, $self_date)[0];
@row = [ 0, '', '', "Program Location: $working_path" ];
push @data, @row;
if ( $link ){
@row = [ 0, '', '', "Started via symbolic link: $link" ];
push @data, @row;
}
@rows = (
[0, '', '', "Developer and Testing Options (Advanced):" ],
['1', '', '--dbg', "Switches on specific debuggers. Refer to inxi-values.txt documentation for active switches." ],
['0', '', '', $line ]
[ 0, '', '', "Website:^https://github.com/smxi/inxi^or^https://smxi.org/" ],
[ 0, '', '', "IRC:^irc.oftc.net channel:^#smxi" ],
[ 0, '', '', "Forums:^https://techpatterns.com/forums/forum-33.html" ],
[ 0, '', '', " " ],
[ 0, '', '', "$self_name - the universal, portable, system information tool
for console and irc." ],
[ 0, '', '', "Using Perl version: $]"],
[ 0, '', '', " " ],
[ 0, '', '', "This program started life as a fork of Infobash 3.02:
Copyright^(C)^2005-2007^Michiel^de^Boer^aka^locsmif." ],
[ 0, '', '', "Subsequent changes and modifications (after Infobash 3.02):
Copyright^(C)^2008-$year^Harald^Hope^aka^h2.
CPU/Konversation^fixes:^Scott^Rogers^aka^trash80.
USB^audio^fixes:^Steven^Barrett^aka^damentz." ],
[ 0, '', '', '' ],
[ 0, '', '', "This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later version.
(https://www.gnu.org/licenses/gpl.html)" ]
);
push @data, @rows;
}
@ -4567,7 +4628,7 @@ sub clean_characters {
sub cleaner {
my ($item) = @_;
return $item if !$item;# handle cases where it was 0 or ''
$item =~ s/chipset|components|computing|computer|corporation|communications|electronics|electrical|electric|gmbh|group|incorporation|industrial|international|nee|revision|semiconductor|software|technologies|technology|ltd\.|<ltd>|inc\.|<inc>|intl\.|co\.|<co>|corp\.|<corp>|\(tm\)|\(r\)|®|\(rev ..\)|\'|\"|\sinc\s*$|\?//gi;
$item =~ s/chipset|components|computing|computer|corporation|communications|electronics|electrical|electric|gmbh|group|incorporation|industrial|international|nee|revision|semiconductor|software|technologies|technology|ltd\.|<ltd>|\bltd\b|inc\.|<inc>|\binc\b|intl\.|co\.|<co>|corp\.|<corp>|\(tm\)|\(r\)|®|\(rev ..\)|\'|\"|\sinc\s*$|\?//gi;
$item =~ s/,|\*/ /g;
$item =~ s/\s\s+/ /g;
$item =~ s/^\s+|\s+$//g;
@ -4606,7 +4667,7 @@ sub remove_duplicates {
# args: $1 - size in KB, return KB, MB, GB, TB, PB, EB
sub get_size {
my ($size) = @_;
my ($size,$b_int) = @_;
my (@data);
return ('','') if ! defined $size;
if ($size !~ /^[0-9\.]+$/){
@ -4637,6 +4698,7 @@ sub get_size {
$data[0] = sprintf("%.0f",$size);
$data[1] = 'KiB';
}
$data[0] = int($data[0]) if $b_int && $data[0];
return @data;
}
@ -4733,6 +4795,7 @@ sub row_defaults {
'pci-slot-data' => "No PCI slot data found. SOC?",
'raid-data' => "No RAID data was found.",
'ram-data' => "No RAM data was found. SOC?",
'root-required' => "<root required>",
'sensors-data-ipmi' => "No ipmi sensors data was found.",
'sensors-data-linux' => "No sensors data was found. Is sensors configured?",
'sensors-ipmi-root' => "Unable to run ipmi sensors. Are you root?",
@ -4832,7 +4895,7 @@ sub generate_json {
print "$json";
}
else {
print_line("Writing json data to: $output_file\n");
print_line("Writing JSON data to: $output_file\n");
open(my $fh, '>', $output_file) or error_handler('open',$output_file,"$!");
print $fh "$json";
close $fh;
@ -4859,7 +4922,7 @@ sub generate_xml {
print "$xml";
}
else {
print_line("Writing json data to: $output_file\n");
print_line("Writing XML data to: $output_file\n");
open(my $fh, '>', $output_file) or error_handler('open',$output_file,"$!");
print $fh "$xml";
close $fh;
@ -5182,65 +5245,6 @@ sub print_line {
}
}
sub show_version {
require Cwd;
import Cwd;
# if not in PATH could be either . or directory name, no slash starting
my $working_path=$self_path;
my (@data, @row, @rows, $link, $self_string);
if ( $working_path eq '.' ){
$working_path = getcwd();
}
elsif ( $working_path !~ /^\// ){
$working_path = getcwd() . "/$working_path";
}
# handle if it's a symbolic link, rare, but can happen with directories
# in irc clients which would only matter if user starts inxi with -! 30 override
# in irc client
if ( -l "$working_path/$self_name" ){
$link="$working_path/$self_name";
$working_path = readlink "$working_path/$self_name";
$working_path =~ s/[^\/]+$//;
}
# strange output /./ ending, but just trim it off, I don't know how it happens
$working_path =~ s%/\./%/%;
@row = [ 0, '', '', "$self_name $self_version-$self_patch ($self_date)"];
push @data, @row;
if ( ! $b_irc ){
my $year = (split/-/, $self_date)[0];
@row = [ 0, '', '', "Program Location: $working_path" ];
push @data, @row;
if ( $link ){
@row = [ 0, '', '', "Started via symbolic link: $link" ];
push @data, @row;
}
@rows = (
[ 0, '', '', "Website:^https://github.com/smxi/inxi^or^https://smxi.org/" ],
[ 0, '', '', "IRC:^irc.oftc.net channel:^#smxi" ],
[ 0, '', '', "Forums:^https://techpatterns.com/forums/forum-33.html" ],
[ 0, '', '', " " ],
[ 0, '', '', "$self_name - the universal, portable, system information tool
for console and irc." ],
[ 0, '', '', "Using Perl version: $]"],
[ 0, '', '', " " ],
[ 0, '', '', "This program started life as a fork of Infobash 3.02:
Copyright^(C)^2005-2007^Michiel^de^Boer^a.k.a.^locsmif." ],
[ 0, '', '', "Subsequent changes and modifications (after Infobash 3.02):
Copyright^(C)^2008-$year^Harald^Hope^aka^h2.
CPU/Konversation^fixes:^Scott^Rogers^aka^trash80.
USB^audio^fixes:^Steven^Barrett^aka^damentz." ],
[ 0, '', '', '' ],
[ 0, '', '', "This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later version.
(https://www.gnu.org/licenses/gpl.html)" ]
);
push @data, @rows;
}
print_basic(@data);
exit 1;
}
########################################################################
#### DATA PROCESSORS
########################################################################
@ -6599,10 +6603,10 @@ sub cpu_properties {
$cache = $cpu{'l2-cache'} * $phyical_count;
}
if ($cache > 10000){
$cache = sprintf("%.02f MB",$cache/1024);
$cache = sprintf("%.01f MiB",$cache/1024); # trim to no decimals?
}
elsif ($cache > 0){
$cache = "$cache KB";
$cache = "$cache KiB";
}
if ($cpu{'cur-freq'} && $cpu{'min-freq'} && $cpu{'max-freq'} ){
$min_max = "$cpu{'min-freq'}/$cpu{'max-freq'} MHz";
@ -7510,6 +7514,9 @@ sub partition_table {
$return[0] = $set_cmd;
}
else {
# runs as user, but is SLOW: udisksctl info -b /dev/sda
# line: org.freedesktop.UDisks2.PartitionTable:
# Type: dos
if (!$b_root){
if ($program = main::check_program('udevadm')){
$return[0] = "$program info -q property -n ";
@ -9366,7 +9373,7 @@ sub create_output {
my $model = $devices{$key}{'model'};
$model ||= 'N/A';
@data = ({
main::key($num++,$devices{$key}{'type'}) => "/dev/$key",
main::key($num++,ucfirst($devices{$key}{'type'})) => "/dev/$key",
main::key($num++,'vendor') => $vendor,
main::key($num++,'model') => $model,
});
@ -10328,9 +10335,9 @@ sub create_output {
my $count = scalar @arrays;
foreach $ref3 (@arrays){
my %row2 = %$ref3;
$num = 1;
if ($count > 1){
$j = scalar @rows;
$num = 1;
@sizes = ($row2{'size'}) ? main::get_size($row2{'size'}) : ();
$size = (@sizes) ? "$sizes[0] $sizes[1]" : 'N/A';
@sizes = ($row2{'free'}) ? main::get_size($row2{'free'}) : ();
@ -10394,6 +10401,7 @@ sub create_output {
}
if ($row{'type'} eq 'mdraid' && $extra > 0 ){
$j = scalar @rows;
$num = 1;
#print Data::Dumper::Dumper \@arrays_holder;
$rows[$j]{main::key($num++,'Info')} = '';
$raid = (defined $arrays_holder[0]{'raid'}) ? $arrays_holder[0]{'raid'}: 'no-raid';
@ -10439,6 +10447,7 @@ sub create_output {
}
}
eval $end if $b_log;
#print Data::Dumper::Dumper \@rows;
return @rows;
}
sub raid_data {
@ -10849,7 +10858,7 @@ sub create_output {
$rows[$j]{main::key($num++,'part-no')} = $mod{'part-number'};
}
if ($extra > 2 ){
$mod{'serial'} ||= 'N/A';
$mod{'serial'} = main::apply_filter($mod{'serial'});
$rows[$j]{main::key($num++,'serial')} = $mod{'serial'};
}
}
@ -11078,6 +11087,7 @@ sub data_processor {
my (@ram) = @_;
my $b_debug = 0;
my (@return,@temp);
my $est = 'est.';
foreach (@ram){
# because we use the actual array handle as the index,
@ -11108,7 +11118,7 @@ sub data_processor {
if ( $ref{'max-module-size'} && $ref{'derived-module-size'} &&
$ref{'derived-module-size'} > $ref{'max-module-size'} ){
$ref{'max-module-size'} = $ref{'derived-module-size'};
$est_mod = 'est';
$est_mod = $est;
}
if ($b_debug){
print "3: dcf: $ref{'device-count-found'} :dms: $ref{'derived-module-size'} :mc: $max_cap :uc: $ref{'used-capacity'}\n";
@ -11123,18 +11133,18 @@ sub data_processor {
if ($ref{'max-module-size'} &&
$ref{'used-capacity'} < ($ref{'slots-16'} * $ref{'max-module-size'} )){
$max_cap = $ref{'slots-16'} * $ref{'max-module-size'};
$est_cap = 'est';
$est_cap = $est;
print "A\n" if $b_debug;
}
elsif ($ref{'derived-module-size'} &&
$ref{'used-capacity'} < ($ref{'slots-16'} * $ref{'derived-module-size'}) ){
$max_cap = $ref{'slots-16'} * $ref{'derived-module-size'};
$est_cap = 'est';
$est_cap = $est;
print "B\n" if $b_debug;
}
else {
$max_cap = $ref{'used-capacity'};
$est_cap = 'est';
$est_cap = $est;
print "C\n" if $b_debug;
}
}
@ -11146,12 +11156,12 @@ sub data_processor {
if ($ref{'slots-16'} > 1 && $ref{'device-count-found'} > 1 &&
$max_cap < ($ref{'derived-module-size'} * $ref{'slots-16'} ) ){
$max_cap = $ref{'derived-module-size'} * $ref{'slots-16'};
$est_cap = 'est';
$est_cap = $est;
print "D\n" if $b_debug;
}
elsif ($ref{'device-count-found'} > 0 && $max_cap < ( $ref{'derived-module-size'} * $ref{'device-count-found'} )){
$max_cap = $ref{'derived-module-size'} * $ref{'device-count-found'};
$est_cap = 'est';
$est_cap = $est;
print "E\n" if $b_debug;
}
## handle cases where we have type 5 data: mms x device count equals type 5 max cap
@ -11161,7 +11171,7 @@ sub data_processor {
$ref{'max-capacity-5'} != $ref{'max-capacity-16'} &&
$ref{'derived-module-size'} != ($ref{'max-capacity-16'}/$ref{'slots-16'}) ){
$max_cap = $ref{'max-capacity-5'};
$est_cap = 'est';
$est_cap = $est;
print "F\n" if $b_debug;
}
@ -11199,7 +11209,7 @@ sub data_processor {
else {
$ref{'max-module-size'} = sprintf("%.f",$max_cap/$slots);
}
$est_mod = 'est';
$est_mod = $est;
}
}
# case where listed max cap is too big for actual slots x max cap, eg:
@ -11317,13 +11327,13 @@ sub get {
}
sub get_repos_linux {
eval $start if $b_log;
my (@content,@data,@data2,@data3,@files,$repo,@rows);
my (@content,@data,@data2,@data3,@files,$repo,@repos,@rows);
my ($key,$path);
my $apk = '/etc/apk/repositories';
my $apt = '/etc/apt/sources.list';
my $eopkg_dir = '/var/lib/eopkg/';
my $pacman = '/etc/pacman.conf';
my $pacman_frugalware = '/etc/pacman-g2.conf';
my $pacman_g2 = '/etc/pacman-g2.conf';
my $pisi_dir = '/etc/pisi/';
my $portage_dir = '/etc/portage/repos.conf/';
my $slackpkg = '/etc/slackpkg/mirrors';
@ -11448,19 +11458,29 @@ sub get_repos_linux {
@files = ();
}
# pacman: Arch and derived
if (-f $pacman || -f $pacman_frugalware){
$pacman = $pacman_frugalware if (-f $pacman_frugalware && ! -f $pacman );
if (-f $pacman || -f $pacman_g2){
$repo = 'pacman';
if (-f $pacman_g2 ){
$pacman = $pacman_g2;
$repo = 'pacman-g2';
}
@files = main::reader($pacman,'strip');
@files = grep {/^\s*Include/i} @files if @files;
@files = map {
my @working = split( /\s+=\s+/, $_);
$working[1];
} @files if @files;
if (@files){
@repos = grep {/^\s*Server/i} @files;
@files = grep {/^\s*Include/i} @files;
}
if (@files){
@files = map {
my @working = split( /\s+=\s+/, $_);
$working[1];
} @files;
}
@files = sort(@files);
@files = main::uniq(@files);
foreach (sort @files){
unshift @files, $pacman if @repos;
foreach (@files){
if (-f $_){
@data = repo_builder($_,'pacman','^\s*Server','\s*=\s*',1);
@data = repo_builder($_,$repo,'^\s*Server','\s*=\s*',1);
@rows = (@rows,@data);
}
else {
@ -11473,6 +11493,12 @@ sub get_repos_linux {
@rows = (@rows,@data);
}
}
if (!@rows){
@data = (
{main::key($num++,repo_builder('missing','no-files')) => $pacman },
);
@rows = (@rows,@data);
}
}
# slackware
if (-f $slackpkg || -f $slackpkg_plus){
@ -11871,6 +11897,7 @@ sub repo_builder {
'bsd-nf' => 'No BSD pkg server files found',
'eopkg' => 'No active eopkg repos found',
'pacman' => 'No active pacman repos in',
'pacman-g2' => 'No active pacman-g2 repos in',
'pisi' => 'No active pisi repos found',
'portage' => 'No enabled portage sources in',
'portsnap' => 'No ports servers in',
@ -11881,6 +11908,7 @@ sub repo_builder {
'openbsd-nf' => 'No OpenBSD pkg mirror files found',
'netbsd' => 'No NetBSD pkg servers in',
'netbsd-nf' => 'No NetBSD pkg server files found',
'no-files' => 'No repo files found in',
'slackpkg' => 'No active slackpkg repos in',
'slackpkg+' => 'No active slackpkg+ repos in',
'yum' => 'No active yum repos in',
@ -11896,6 +11924,7 @@ sub repo_builder {
'freebsd' => 'FreeBSD update server',
'freebsd-pkg' => 'FreeBSD default pkg server',
'pacman' => 'Active pacman repo servers in',
'pacman-g2' => 'Active pacman-g2 repo servers in',
'pisi' => 'Active pisi repo',
'portage' => 'Enabled portage sources in',
'portsnap' => 'BSD ports server',
@ -12940,7 +12969,7 @@ sub create_output {
}
else {
if (main::check_program('file')){
$fs = ($b_root) ? 'N/A' : 'root required' ;
$fs = ($b_root) ? 'N/A' : main::row_defaults('root-required');
}
else {
$fs = 'requires file';
@ -13129,7 +13158,7 @@ sub usb_data {
@row = split /:/, $line;
next if ! defined $row[0];
if ($row[0] eq 'bcdUSB' && defined $row[1]){
$speed = $row[1];
$speed = sprintf("%1.1f",$row[1]);
}
elsif ($row[0] eq '~bInterfaceProtocol' && $row[2] ){
$protocol = $row[2];
@ -13155,7 +13184,7 @@ sub usb_data {
@row = split /:/, $line;
next if ! defined $row[0];
if ($row[0] eq 'bcdUSB' && defined $row[1]){
$speed = $row[1];
$speed = sprintf("%.1f",$row[1]);
}
elsif ($row[0] eq 'bDeviceClass' && defined $row[1] && $row[1] == 9){
$b_hub = 1;

685
inxi.1

File diff suppressed because it is too large Load diff

View file

@ -1,3 +1,24 @@
=====================================================================================
Version: 2.9.12
Patch Version: 00
Script Date: 2018-04-06
-----------------------------------
Changes:
-----------------------------------
New version, man page. Finished up main man edits. Set new defaults for some options,
like --sleep and -t.
Edits to layout and language, removed some legacy options and language from man and
inxi.
Added partition table detections, rough initial stage. Only works on systems with
udev present currently, will be expanded as we find fast tools. Since the systemd
method is literally up to 25x slower than the udev method, it's not being considered
except maybe as a last, last resort, and probably will never be used.
-----------------------------------
-- Harald Hope - Fri, 06 Apr 2018 15:49:02 -0700
=====================================================================================
Version: 2.9.11
Patch Version: 00