Bugs!! Fixes! Spring cleaning!

Because these are either newly created, or newly discovered, bugs,
this release was pushed as early as possible to get them fixed asap.

BUGS:
1. Desktop: Lumina detection had a syntax error which made it not work.
This has been broken for a while.

2. Logical: if not root, and if LUKS / bcache detected, failed to load
proc_partitions, which generates error on --logical --admin since the
required components data was not loaded. This was an oversight.

3. The 3.3.02 ShellData refactor created a bug for console IRC, showed
shell, not irc client, name, and set default shell data which also
showed.

4. Console IRC tty: there was also an older bug that made -S, -G
not work consistently, and there were errors that had been missed
for many years in that logic. These should all be corrected, console
irc out of display, or in display as root, should now show tty info,
tty size in -G.

FIXES:
1. Memory: restored $bsd_type block on /proc/meminfo and force NetBSD
to use a corrected vmstat. This leaves that block of logic to correct
the NetBSD oddities in meminfo, but it may fix future isses that popup.

2. -Sxxx man page item incorrectly said XDG_VTNR was systemd/linux, it's
not, it's various things, GhostBSD has it, for example. See what you get
for believing what people say!

3. Logical: added in N/A for null maj-min in --logical report. While
bug 2 triggered those errors, there could be future cases where maj-min
are null, like BSD lvm data etc.

ENHANCEMENTS:
1. Going along with Fix 1, added '--force meminfo' in case you really want that.

2. Distro: System Base: Added TrueNAS detection.

3. Package Data: Added mport [MidnightBSD] type. That requires root to run
for some odd reason, so won't see the best output if not root.

CHANGES:
1. Moved logical to -v7 from -v8, it's stable enough now.

CODE CHANGES:
1. Moved get_tty_number and get_tty_console_irc to ShellData:tty_number
and ShellData::tty_console_irc.

ShellData::tty_number was being loaded several times, added
$loaded{'tty-number'} test, and made client{'tty-number'} to store value.

tty_console_irc changed to console_irc_tty, which is what it gets, removed
hacks and made it load once and store result in client hash.

2. Optimization: retested sub vs package::method and they run at exactly
the same time, give or take, so moving more stuff into packages to make
it easier to maintain.
This commit is contained in:
Harald Hope 2021-03-17 19:39:02 -07:00
parent c54ff52417
commit 3d4d1f533c
3 changed files with 224 additions and 91 deletions

214
inxi
View file

@ -36,14 +36,14 @@ use Getopt::Long qw(GetOptions);
Getopt::Long::Configure ('bundling', 'no_ignore_case', Getopt::Long::Configure ('bundling', 'no_ignore_case',
'no_getopt_compat', 'no_auto_abbrev','pass_through'); 'no_getopt_compat', 'no_auto_abbrev','pass_through');
use POSIX qw(uname strftime ttyname); use POSIX qw(uname strftime ttyname);
# use Benchmark qw(:all); use Benchmark qw(:all);
# use Devel::Size qw(size total_size); # use Devel::Size qw(size total_size);
# use feature qw(say state); # 5.10 or newer Perl # use feature qw(say state); # 5.10 or newer Perl
## INXI INFO ## ## INXI INFO ##
my $self_name='inxi'; my $self_name='inxi';
my $self_version='3.3.02'; my $self_version='3.3.03';
my $self_date='2021-03-15'; my $self_date='2021-03-17';
my $self_patch='00'; my $self_patch='00';
## END INXI INFO ## ## END INXI INFO ##
@ -105,7 +105,7 @@ my $sensors_cpu_nu = 0;
my ($dl_ua,$weather_source,$weather_unit) = ('s-tools/' . $self_name . '-',100,'mi'); my ($dl_ua,$weather_source,$weather_unit) = ('s-tools/' . $self_name . '-',100,'mi');
## Tools ## Tools
my ($bt_tool,$display,$ftp_alt,$tty_session); my ($bt_tool,$display,$ftp_alt);
my ($display_opt,$sudoas) = ('',''); my ($display_opt,$sudoas) = ('','');
## Output ## Output
@ -3642,7 +3642,7 @@ sub set_program_values {
'kwin_x11' => ['^kwin_x11',0,'0','kwin_x11',0,1,0,'',''],# no version 'kwin_x11' => ['^kwin_x11',0,'0','kwin_x11',0,1,0,'',''],# no version
'larswm' => ['^larswm',2,'-v','larswm',0,1,1,'',''], 'larswm' => ['^larswm',2,'-v','larswm',0,1,1,'',''],
'liri' => ['^liri',0,'0','liri',0,1,0,'',''], 'liri' => ['^liri',0,'0','liri',0,1,0,'',''],
'lumina' => ['^\S',1,'--version','Lumina',0,1,1,'',''], 'lumina-desktop' => ['^\S',1,'--version','Lumina',0,1,1,'',''],
'lwm' => ['^lwm',0,'0','lwm',0,1,0,'',''], # no version 'lwm' => ['^lwm',0,'0','lwm',0,1,0,'',''], # no version
'lxpanel' => ['^lxpanel',2,'--version','LXDE',0,1,0,'',''], 'lxpanel' => ['^lxpanel',2,'--version','LXDE',0,1,0,'',''],
# command: lxqt-panel # command: lxqt-panel
@ -4481,13 +4481,13 @@ sub get {
$show{'bluetooth-forced'} = 1; $show{'bluetooth-forced'} = 1;
$show{'cpu-flag'} = 1; $show{'cpu-flag'} = 1;
$show{'ip'} = 1; $show{'ip'} = 1;
$show{'logical'} = 1;
$show{'raid-forced'} = 1; $show{'raid-forced'} = 1;
$extra = 3; $extra = 3;
} }
if ($arg >= 8 ){ if ($arg >= 8 ){
$b_admin = 1; $b_admin = 1;
$trigger{'downloader'} = 1; $trigger{'downloader'} = 1;
$show{'logical'} = 1;
$show{'process'} = 1; $show{'process'} = 1;
$show{'ps-cpu'} = 1; $show{'ps-cpu'} = 1;
$show{'ps-mem'} = 1; $show{'ps-mem'} = 1;
@ -4733,8 +4733,8 @@ sub get {
'force:s' => sub { 'force:s' => sub {
my ($opt,$arg) = @_; my ($opt,$arg) = @_;
if ($arg){ if ($arg){
my $wl = 'display|dmidecode|hddtemp|lsusb|man|no-dig|no-doas|no-html-wan|'; my $wl = 'display|dmidecode|hddtemp|lsusb|man|meminfo|';
$wl .= 'no-sudo|usb-sys|vmstat|wmctrl'; $wl .= 'no-dig|no-doas|no-html-wan|no-sudo|usb-sys|vmstat|wmctrl';
for (split(',',$arg)){ for (split(',',$arg)){
if ($_ =~ /\b($wl)\b/){ if ($_ =~ /\b($wl)\b/){
$force{lc($1)} = 1; $force{lc($1)} = 1;
@ -5113,10 +5113,10 @@ sub show_options {
['2', '6', '', "Full $partition_string (-p), ['2', '6', '', "Full $partition_string (-p),
unmounted $partition_string (-o), optical drive (-d), USB (-J), unmounted $partition_string (-o), optical drive (-d), USB (-J),
full RAID; triggers -xx." ], full RAID; triggers -xx." ],
['2', '7', '', "Network IP data (-i), bluetooth and RAID forced; ['2', '7', '', "Network IP data (-i), bluetooth, logical (-L),
triggers -xxx."], RAID forced; triggers -xxx."],
['2', '8', '', "Everything available, including logical (-L), ['2', '8', '', "Everything available, including repos (-r),
repos (-r), processes (-tcm), PCI slots (--slots); triggers admin (-a)."], processes (-tcm), PCI slots (--slots); triggers admin (-a)."],
); );
# if distro maintainers don't want the weather feature disable it # if distro maintainers don't want the weather feature disable it
if ( $use{'weather'} ){ if ( $use{'weather'} ){
@ -5346,8 +5346,9 @@ sub show_options {
['1', '', '--dmidecode', "Force use of dmidecode data instead of /sys where relevant ['1', '', '--dmidecode', "Force use of dmidecode data instead of /sys where relevant
(e.g. -M, -B)." ], (e.g. -M, -B)." ],
['1', '', '--downloader', "Force $self_name to use [curl|fetch|perl|wget] for downloads." ], ['1', '', '--downloader', "Force $self_name to use [curl|fetch|perl|wget] for downloads." ],
['1', '', '--force', "[dmidecode|hddtemp|lsusb|usb-sys|vmstat|wmctl]. Force use of item, ['1', '', '--force', "[dmidecode|hddtemp|lsusb|meminfo|usb-sys|vmstat|wmctl]. 1 or more
see --hddtemp, --dmidecode, --wm, --usb-tool, --usb-sys." ], in comma separated list. Force use of item(s).
See --hddtemp, --dmidecode, --wm, --usb-tool, --usb-sys." ],
['1', '', '--hddtemp', "Force use of hddtemp for disk temps." ], ['1', '', '--hddtemp', "Force use of hddtemp for disk temps." ],
['1', '', '--host', "Turn on hostname for -S." ], ['1', '', '--host', "Turn on hostname for -S." ],
['1', '', '--html-wan', "Overrides configuration item NO_HTML_WAN (resets to default)." ], ['1', '', '--html-wan', "Overrides configuration item NO_HTML_WAN (resets to default)." ],
@ -5535,7 +5536,7 @@ sub get_client_name {
if ($ppid && -e "/proc/$ppid/exe" ){ if ($ppid && -e "/proc/$ppid/exe" ){
$client_name = lc(readlink "/proc/$ppid/exe"); $client_name = lc(readlink "/proc/$ppid/exe");
$client_name =~ s/^.*\///; $client_name =~ s/^.*\///;
if ($client_name =~ /^bash|dash|sh|python.*|perl.*$/){ if ($client_name =~ /^(bash|csh|dash|fish|sh|python.*|perl.*|zsh)$/){
$pppid = (main::grabber("ps -wwp $ppid -o ppid"))[1]; $pppid = (main::grabber("ps -wwp $ppid -o ppid"))[1];
#my @temp = (main::grabber("ps -wwp $ppid -o ppid 2>/dev/null"))[1]; #my @temp = (main::grabber("ps -wwp $ppid -o ppid 2>/dev/null"))[1];
$pppid =~ s/^\s+|\s+$//g; $pppid =~ s/^\s+|\s+$//g;
@ -5590,7 +5591,7 @@ sub get_client_version {
$client{'name-print'} = $app[3]; $client{'name-print'} = $app[3];
$client{'console-irc'} = $app[4]; $client{'console-irc'} = $app[4];
} }
if ($client{'name'} =~ /^bash|dash|sh$/ ){ if ($client{'name'} =~ /^(bash|csh|fish|dash|sh|zsh)$/ ){
$client{'name-print'} = 'shell wrapper'; $client{'name-print'} = 'shell wrapper';
$client{'console-irc'} = 1; $client{'console-irc'} = 1;
} }
@ -12037,11 +12038,14 @@ sub tty_data(){
if ($size{'term-cols'}){ if ($size{'term-cols'}){
$tty = "$size{'term-cols'}x$size{'term-lines'}"; $tty = "$size{'term-cols'}x$size{'term-lines'}";
} }
# this is broken
elsif ($b_irc && $client{'console-irc'}){ elsif ($b_irc && $client{'console-irc'}){
my $tty_working = main::get_tty_console_irc('tty'); ShellData::console_irc_tty() if !$loaded{'con-irc-tty'};
if (my $program = main::check_program('stty')){ my $tty_working = $client{'con-irc-tty'};
if ($tty_working ne '' && (my $program = main::check_program('stty'))){
my $tty_arg = ($bsd_type) ? '-f' : '-F'; my $tty_arg = ($bsd_type) ? '-f' : '-F';
$tty = (main::grabber("$program $tty_arg /dev/pts/$tty_working size 2>/dev/null"))[0]; $tty_working = "tty$tty_working" if main::is_numeric($tty_working);
$tty = (main::grabber("$program $tty_arg /dev/$tty_working size 2>/dev/null"))[0];
if ($tty){ if ($tty){
my @temp = split(/\s+/, $tty); my @temp = split(/\s+/, $tty);
$tty = "$temp[1]x$temp[0]"; $tty = "$temp[1]x$temp[0]";
@ -12434,6 +12438,7 @@ sub components_recursive_output {
$$rows[$$j]->{main::key($$num++,1,$l2,$id)} = $component->[0]; $$rows[$$j]->{main::key($$num++,1,$l2,$id)} = $component->[0];
if ($extra > 1){ if ($extra > 1){
if ($b_admin){ if ($b_admin){
$component->[1] ||= 'N/A';
$$rows[$$j]->{main::key($$num++,0,$l3,'maj-min')} = $component->[1]; $$rows[$$j]->{main::key($$num++,0,$l3,'maj-min')} = $component->[1];
$$rows[$$j]->{main::key($$num++,0,$l3,'mapped')} = $component->[3] if $component->[3]; $$rows[$$j]->{main::key($$num++,0,$l3,'mapped')} = $component->[3] if $component->[3];
$size = main::get_size($component->[2],'string','N/A'); $size = main::get_size($component->[2],'string','N/A');
@ -12451,6 +12456,7 @@ sub components_recursive_output {
sub general_data { sub general_data {
eval $start if $b_log; eval $start if $b_log;
my (@found,@general_data,%parent,$parent_fs); my (@found,@general_data,%parent,$parent_fs);
main::set_proc_partitions() if !$loaded{'proc-partitions'};
main::set_mapper() if !$loaded{'mapper'}; main::set_mapper() if !$loaded{'mapper'};
foreach my $row (@lsblk){ foreach my $row (@lsblk){
# bcache doesn't have mapped name: !$mapper{$row->{'name'}} || # bcache doesn't have mapped name: !$mapper{$row->{'name'}} ||
@ -12509,14 +12515,14 @@ sub general_data {
sub lvm_data { sub lvm_data {
eval $start if $b_log; eval $start if $b_log;
$loaded{'lvm-data'} = 1; $loaded{'lvm-data'} = 1;
main::set_proc_partitions() if !$loaded{'proc-partitions'};
main::set_mapper() if !$loaded{'mapper'};
my (@args,@data,%totals); my (@args,@data,%totals);
@args = qw(vg_name vg_fmt vg_size vg_free lv_name lv_layout lv_size @args = qw(vg_name vg_fmt vg_size vg_free lv_name lv_layout lv_size
lv_kernel_major lv_kernel_minor segtype seg_count seg_start_pe seg_size_pe lv_kernel_major lv_kernel_minor segtype seg_count seg_start_pe seg_size_pe
stripes devices raid_mismatch_count raid_sync_action raid_write_behind stripes devices raid_mismatch_count raid_sync_action raid_write_behind
copy_percent); copy_percent);
my $num = 0; my $num = 0;
main::set_proc_partitions() if !$loaded{'proc-partitions'};
main::set_mapper() if !$loaded{'mapper'};
if ($fake{'logical'}){ if ($fake{'logical'}){
#my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/lvm/lvs-test-1.txt"; #my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/lvm/lvs-test-1.txt";
#@data = main::reader($file,'strip'); #@data = main::reader($file,'strip');
@ -12594,7 +12600,6 @@ sub component_data {
my ($maj_min,$full_components) = @_; my ($maj_min,$full_components) = @_;
push(@$full_components, component_recursive_data($maj_min)); push(@$full_components, component_recursive_data($maj_min));
} }
sub component_recursive_data { sub component_recursive_data {
eval $start if $b_log; eval $start if $b_log;
my ($maj_min) = @_; my ($maj_min) = @_;
@ -17252,6 +17257,7 @@ sub get_repos_bsd {
my $freebsd_pkg = '/etc/pkg/FreeBSD.conf'; my $freebsd_pkg = '/etc/pkg/FreeBSD.conf';
my $ghostbsd_pkg = '/etc/pkg/GhostBSD.conf'; my $ghostbsd_pkg = '/etc/pkg/GhostBSD.conf';
my $hardenedbsd_pkg = '/etc/pkg/HardenedBSD.conf'; my $hardenedbsd_pkg = '/etc/pkg/HardenedBSD.conf';
my $mports = '/usr/mports/Makefile';
my $netbsd = '/usr/pkg/etc/pkgin/repositories.conf'; my $netbsd = '/usr/pkg/etc/pkgin/repositories.conf';
my $openbsd = '/etc/pkg.conf'; my $openbsd = '/etc/pkg.conf';
my $openbsd2 = '/etc/installurl'; my $openbsd2 = '/etc/installurl';
@ -17292,7 +17298,7 @@ sub get_repos_bsd {
} }
#print "url:$url\n" if $url; #print "url:$url\n" if $url;
if ($data2[0] eq 'enabled'){ if ($data2[0] eq 'enabled'){
if ($url && $data2[1] eq 'yes'){ if ($url && $data2[1] =~ /^(1|true|yes)$/i){
push(@data3, "$url"); push(@data3, "$url");
} }
$url = ''; $url = '';
@ -17315,7 +17321,7 @@ sub get_repos_bsd {
} }
} }
} }
elsif (-f $openbsd || -f $openbsd2) { if (-f $openbsd || -f $openbsd2) {
if (-f $openbsd){ if (-f $openbsd){
@data = repo_builder($openbsd,'openbsd','^installpath','\s*=\s*',1); @data = repo_builder($openbsd,'openbsd','^installpath','\s*=\s*',1);
push(@rows,@data); push(@rows,@data);
@ -17325,11 +17331,37 @@ sub get_repos_bsd {
push(@rows,@data); push(@rows,@data);
} }
} }
elsif (-f $netbsd){ if (-f $netbsd){
# not an empty row, and not a row starting with # # not an empty row, and not a row starting with #
@data = repo_builder($netbsd,'netbsd','^\s*[^#]+$'); @data = repo_builder($netbsd,'netbsd','^\s*[^#]+$');
push(@rows,@data); push(@rows,@data);
} }
# I don't think this is right, have to find out, for midnightbsd
# if (-f $mports){
# @data = main::reader($mports,'strip');
# main::writer("$debugger_dir/system-repo-data-mports.txt",\@data) if $debugger_dir;
# for (@data){
# if (!/^MASTER_SITE_INDEX/){
# next;
# }
# else {
# push(@data3,(split(/=\s*/,$_))[1]);
# }
# last if /^INDEX/;
# }
# if (!@data3){
# $key = repo_data('missing','mports');
# }
# else {
# url_cleaner(\@data3);
# $key = repo_data('active','mports');
# }
# push(@rows,
# {main::key($num++,1,1,$key) => $mports},
# [@data3],
# );
# @data3 = ();
# }
# BSDs do not default always to having repo files, so show correct error # BSDs do not default always to having repo files, so show correct error
# mesage in that case # mesage in that case
if (!@rows){ if (!@rows){
@ -17374,6 +17406,8 @@ sub repo_data {
'freebsd-missing' => 'No FreeBSD update servers in', 'freebsd-missing' => 'No FreeBSD update servers in',
'freebsd-pkg-active' => 'FreeBSD default pkg server', 'freebsd-pkg-active' => 'FreeBSD default pkg server',
'freebsd-pkg-missing' => 'No FreeBSD default pkg server in', 'freebsd-pkg-missing' => 'No FreeBSD default pkg server in',
'mports-active' => 'mports servers',
'mports-missing' => 'No mports servers found',
'netbsd-active' => 'NetBSD pkg servers', 'netbsd-active' => 'NetBSD pkg servers',
'netbsd-files-missing' => 'No NetBSD pkg server files found', 'netbsd-files-missing' => 'No NetBSD pkg server files found',
'netbsd-missing' => 'No NetBSD pkg servers in', 'netbsd-missing' => 'No NetBSD pkg servers in',
@ -20404,7 +20438,7 @@ sub get_display_manager {
my (@data,@found,$path,$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 # 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 # extension in Arch note: to avoid positives with directories, test for -f
# explicitly, not -e. Guessing on cdm.pid # explicitly, not -e. Guessing on cdm.pid. pcdm uses vt, PCDM-vt9.pid
my @dms = qw(cdm.pid entranced.pid gdm.pid gdm3.pid kdm.pid ldm.pid my @dms = qw(cdm.pid entranced.pid gdm.pid gdm3.pid kdm.pid ldm.pid
lightdm.pid lxdm.pid mdm.pid nodm.pid pcdm.pid sddm.pid slim.lock lightdm.pid lxdm.pid mdm.pid nodm.pid pcdm.pid sddm.pid slim.lock
slim.pid tdm.pid udm.pid wdm.pid xdm.pid xenodm.pid); slim.pid tdm.pid udm.pid wdm.pid xdm.pid xenodm.pid);
@ -20495,12 +20529,23 @@ sub get_bsd_os {
@osr = main::reader($os_release) if -r $os_release; @osr = main::reader($os_release) if -r $os_release;
if (@osr && $bsd_type =~ /($bsd_type_osr)/ && (grep {/($bsd_type_osr)/i} @osr)){ if (@osr && $bsd_type =~ /($bsd_type_osr)/ && (grep {/($bsd_type_osr)/i} @osr)){
$distro = get_os_release(); $distro = get_os_release();
$distro_id = lc($1);
}
}
if (!$distro){
my $bsd_type_version = 'truenas';
my ($version_file,$version_info) = ('/etc/version','');
$version_info = main::reader($version_file,'strip') if -r $version_file;
if ($version_info && $version_info =~ /($bsd_type_version)/i){
$distro = $version_info;
$distro_id = lc($1);
} }
} }
if (!$distro){ if (!$distro){
# seen a case without osx file, or was it permissions? # seen a case without osx file, or was it permissions?
# this covers all the other bsds anyway, no problem. # this covers all the other bsds anyway, no problem.
$distro = "$uname[0] $uname[2]"; $distro = "$uname[0] $uname[2]";
$distro_id = lc($uname[0]);
} }
if ($distro && if ($distro &&
(-e '/etc/pkg/GhostBSD.conf' || -e '/usr/local/etc/pkg/repos/GhostBSD.conf') && (-e '/etc/pkg/GhostBSD.conf' || -e '/usr/local/etc/pkg/repos/GhostBSD.conf') &&
@ -20767,14 +20812,17 @@ sub android_info {
sub system_base_bsd { sub system_base_bsd {
eval $start if $b_log; eval $start if $b_log;
# ghostbsd is handled in main bsd section # ghostbsd is handled in main bsd section
if (lc($uname[1]) eq 'nomadbsd' && $distro =~ /^freebsd/i){ if (lc($uname[1]) eq 'nomadbsd' && $distro_id eq 'freebsd'){
$system_base = $distro; $system_base = $distro;
$distro = $uname[1]; $distro = $uname[1];
} }
if (-f '/etc/pkg/HardenedBSD.conf' && $distro =~ /^freebsd/i){ elsif (-f '/etc/pkg/HardenedBSD.conf' && $distro_id eq 'freebsd'){
$system_base = $distro; $system_base = $distro;
$distro = 'HardenedBSD'; $distro = 'HardenedBSD';
} }
elsif ($distro_id =~ /^(truenas)$/){
$system_base = "$uname[0] $uname[2]";
}
eval $end if $b_log; eval $end if $b_log;
} }
@ -21423,7 +21471,9 @@ sub get {
my ($memory); my ($memory);
# note: netbsd 8.0 has meminfo! # note: netbsd 8.0 has meminfo!
$loaded{'memory'} = 1; $loaded{'memory'} = 1;
if (!$force{'vmstat'} && (my $file = main::system_files('meminfo'))) { # netbsd uses meminfo, but it uses it in a weird way
if (!$force{'vmstat'} && (!$bsd_type || ($force{'meminfo'} && $bsd_type)) &&
(my $file = main::system_files('meminfo'))) {
$memory = meminfo_data($type,$file); $memory = meminfo_data($type,$file);
} }
else { else {
@ -21748,6 +21798,7 @@ sub package_counts {
['guix-sys','guix','p','package -p "/run/current-system/profile" -I',1,0,''], ['guix-sys','guix','p','package -p "/run/current-system/profile" -I',1,0,''],
['guix-usr','guix','p','package -I',1,0,''], ['guix-usr','guix','p','package -I',1,0,''],
['kiss','kiss','p','list',1,0,''], ['kiss','kiss','p','list',1,0,''],
['mport','mport','p','list',1,0,''],
['nix-sys','nix-store','p','-qR /run/current-system/sw',1,1,'-'], ['nix-sys','nix-store','p','-qR /run/current-system/sw',1,1,'-'],
['nix-usr','nix-store','p','-qR ~/.nix-profile',1,1,'-'], ['nix-usr','nix-store','p','-qR ~/.nix-profile',1,1,'-'],
['nix-default','nix-store','p','-qR /nix/var/nix/profiles/default',1,2,'-'], ['nix-default','nix-store','p','-qR /nix/var/nix/profiles/default',1,2,'-'],
@ -21802,7 +21853,7 @@ sub package_counts {
} }
} }
# print Data::Dumper::Dumper \%counts; # print Data::Dumper::Dumper \%counts;
main::log_data('dump','Packaage managers: %counts',\%counts) if $b_log; main::log_data('dump','Package managers: %counts',\%counts) if $b_log;
eval $end if $b_log; eval $end if $b_log;
} }
sub appimage_counts { sub appimage_counts {
@ -22343,52 +22394,55 @@ sub ssh_status {
eval $end if $b_log; eval $end if $b_log;
return $b_ssh; return $b_ssh;
} }
} # If IRC: called if root for -S, -G, or if not in display for user.
sub console_irc_tty {
sub get_tty_console_irc {
eval $start if $b_log; eval $start if $b_log;
my ($type) = @_; $loaded{'con-irc-tty'} = 1;
return $tty_session if defined $tty_session; # not set for root in or out of display
if ( $type eq 'vtrn' && defined $ENV{'XDG_VTNR'} ){ if (defined $ENV{'XDG_VTNR'} ){
$tty_session = $ENV{'XDG_VTNR'}; $client{'con-irc-tty'} = $ENV{'XDG_VTNR'};
} }
else { else {
$tty_session = awk(\@ps_aux,".*$ppid.*$client{'name'}",7,'\s+'); # ppid won't work with name, so this is assuming there's only one client running
$tty_session =~ s/^[^[0-9]+// if $tty_session; # if in display, -G returns vt size, not screen dimensions in rowsxcols.
$client{'con-irc-tty'} = main::awk(\@ps_aux,'.*\b' . $client{'name'} . '\b.*',7,'\s+');
$client{'con-irc-tty'} =~ s/^(tty|\?)// if defined $client{'con-irc-tty'};
} }
$tty_session = '' if ! defined $tty_session; $client{'con-irc-tty'} = '' if !defined $client{'con-irc-tty'};
log_data('data',"conole-irc-tty:$tty_session") if $b_log; main::log_data('data',"console-irc-tty:$client{'con-irc-tty'}") if $b_log;
eval $end if $b_log; eval $end if $b_log;
return $tty_session;
} }
sub tty_number {
sub get_tty_number {
eval $start if $b_log; eval $start if $b_log;
my ($tty); $loaded{'tty-number'} = 1;
# note: ttyname returns undefined if pinxi is > redirected output # note: ttyname returns undefined if pinxi is > redirected output
# variants: /dev/pts/1 /dev/tty1 /dev/ttyp2 /dev/ttyra [hex number a] # variants: /dev/pts/1 /dev/tty1 /dev/ttyp2 /dev/ttyra [hex number a]
$tty = POSIX::ttyname(1); $client{'tty-number'} = POSIX::ttyname(1);
# but tty direct works fine in that case # but tty direct works fine in that case
if (!defined $tty && (my $program = check_program('tty'))){ if (!defined $client{'tty-number'} && (my $program = main::check_program('tty'))){
chomp($tty = qx($program 2>/dev/null)); chomp($client{'tty-number'} = qx($program 2>/dev/null));
if (defined $client{'tty-number'} && $client{'tty-number'} =~ /^not/){
undef $client{'tty-number'};
} }
if (defined $tty){ }
$tty =~ s/^\/dev\/(tty)?//; if (defined $client{'tty-number'}){
$client{'tty-number'} =~ s/^\/dev\/(tty)?//;
} }
else { else {
$tty = ''; $client{'tty-number'} = '';
} }
# systemd only item, usually same as tty in console, not defined # systemd only item, usually same as tty in console, not defined
# for root or non systemd systems. # for root or non systemd systems.
if (defined $ENV{'XDG_VTNR'} && $tty ne '' && $ENV{'XDG_VTNR'} ne $tty){ if (defined $ENV{'XDG_VTNR'} && $client{'tty-number'} ne '' &&
$tty = "$tty (vt $ENV{'XDG_VTNR'})"; $ENV{'XDG_VTNR'} ne $client{'tty-number'}){
$client{'tty-number'} = "$client{'tty-number'} (vt $ENV{'XDG_VTNR'})";
} }
elsif ($tty eq '' && defined $ENV{'XDG_VTNR'}) { elsif ($client{'tty-number'} eq '' && defined $ENV{'XDG_VTNR'}) {
$tty = $ENV{'XDG_VTNR'}; $client{'tty-number'} = $ENV{'XDG_VTNR'};
} }
log_data('data',"tty:$tty") if $b_log; main::log_data('data',"tty:$client{'tty-number'}") if $b_log;
eval $end if $b_log; eval $end if $b_log;
return $tty; }
} }
sub get_uptime { sub get_uptime {
@ -23509,7 +23563,7 @@ sub set_lsblk {
} }
} }
} }
#print Data::Dumper::Dumper \@lsblk; print Data::Dumper::Dumper \@lsblk if $dbg[32];
main::log_data('dump','@lsblk',\@lsblk) if $b_log; main::log_data('dump','@lsblk',\@lsblk) if $b_log;
eval $end if $b_log; eval $end if $b_log;
} }
@ -24704,12 +24758,6 @@ sub generate_short_data {
eval $start if $b_log; eval $start if $b_log;
my $num = 0; my $num = 0;
my $kernel_os = ($bsd_type) ? 'OS' : 'Kernel'; my $kernel_os = ($bsd_type) ? 'OS' : 'Kernel';
ShellData::set() if !$loaded{'shell-data'} && $ppid;
my $client = $client{'name-print'};
my $client_shell = ($b_irc) ? 'Client' : 'Shell';
if ($client{'version'}){
$client .= ' ' . $client{'version'};
}
my ($cpu_string,$speed,$speed_key,$type) = ('','','speed',''); my ($cpu_string,$speed,$speed_key,$type) = ('','','speed','');
my $memory = MemoryData::get('string'); my $memory = MemoryData::get('string');
my @cpu = CpuData::get('short'); my @cpu = CpuData::get('short');
@ -24767,8 +24815,16 @@ sub generate_short_data {
$disk_string = "$used/$size"; $disk_string = "$used/$size";
} }
} }
#print join('; ', @cpu), " sleep: $cpu_sleep\n";
$memory ||= 'N/A'; $memory ||= 'N/A';
#print join('; ', @cpu), " sleep: $cpu_sleep\n";
if (!$loaded{'shell-data'} && $ppid && (!$b_irc || !$client{'name-print'})){
ShellData::set();
}
my $client = $client{'name-print'};
my $client_shell = ($b_irc) ? 'Client' : 'Shell';
if ($client{'version'}){
$client .= ' ' . $client{'version'};
}
my @data = ({ my @data = ({
main::key($num++,0,0,'CPU') => $cpu_string, main::key($num++,0,0,'CPU') => $cpu_string,
main::key($num++,0,0,$speed_key) => $speed, main::key($num++,0,0,$speed_key) => $speed,
@ -24809,9 +24865,6 @@ sub generate_info_data {
$b_gcc = 1; $b_gcc = 1;
} }
$gcc ||= 'N/A'; $gcc ||= 'N/A';
ShellData::set() if !$loaded{'shell-data'} && $ppid;
my $client_shell = ($b_irc) ? 'Client' : 'Shell';
my $client = $client{'name-print'};
my %data = ( my %data = (
$data_name => [{ $data_name => [{
main::key($num++,0,1,'Processes') => scalar @ps_aux, main::key($num++,0,1,'Processes') => scalar @ps_aux,
@ -24895,6 +24948,11 @@ sub generate_info_data {
$data{$data_name}->[$index]{$_} = $packages{$_}; $data{$data_name}->[$index]{$_} = $packages{$_};
} }
} }
if (!$loaded{'shell-data'} && $ppid && (!$b_irc || !$client{'name-print'})){
ShellData::set();
}
my $client_shell = ($b_irc) ? 'Client' : 'Shell';
my $client = $client{'name-print'};
if (!$b_irc && $extra > 1){ if (!$b_irc && $extra > 1){
# some bsds don't support -f option to get PPPID # some bsds don't support -f option to get PPPID
# note: root/su - does not have $DISPLAY usually # note: root/su - does not have $DISPLAY usually
@ -24902,22 +24960,23 @@ sub generate_info_data {
$parent = ShellData::shell_launcher(); $parent = ShellData::shell_launcher();
} }
else { else {
$parent = get_tty_number(); ShellData::tty_number() if !$loaded{'tty-number'};
$parent = "tty $parent" if $parent ne ''; $parent = "tty $client{'tty-number'}" if $client{'tty-number'} ne '';
} }
# can be tty 0 so test for defined # can be tty 0 so test for defined
$running_in = $parent if $parent; $running_in = $parent if $parent;
if ($extra > 2 && $running_in && ShellData::ssh_status() ){ if ($extra > 2 && $running_in && ShellData::ssh_status() ){
$running_in .= ' (SSH)'; $running_in .= ' (SSH)';
} }
}
if ($extra > 2 && $client{'su-start'}){ if ($extra > 2 && $client{'su-start'}){
$client .= " ($client{'su-start'})"; $client .= " ($client{'su-start'})";
} }
}
$data{$data_name}->[$index]{main::key($num++,1,1,$client_shell)} = $client; $data{$data_name}->[$index]{main::key($num++,1,1,$client_shell)} = $client;
if ($extra > 0 && $client{'version'}){ if ($extra > 0 && $client{'version'}){
$data{$data_name}->[$index]{main::key($num++,0,2,'v')} = $client{'version'}; $data{$data_name}->[$index]{main::key($num++,0,2,'v')} = $client{'version'};
} }
if (!$b_irc){
if ($extra > 2 && $client{'default-shell'}){ if ($extra > 2 && $client{'default-shell'}){
$data{$data_name}->[$index]{main::key($num++,1,2,'default')} = $client{'default-shell'}; $data{$data_name}->[$index]{main::key($num++,1,2,'default')} = $client{'default-shell'};
$data{$data_name}->[$index]{main::key($num++,0,3,'v')} = $client{'default-shell-v'} if $client{'default-shell-v'}; $data{$data_name}->[$index]{main::key($num++,0,3,'v')} = $client{'default-shell-v'} if $client{'default-shell-v'};
@ -24925,8 +24984,8 @@ sub generate_info_data {
if ($running_in){ if ($running_in){
$data{$data_name}->[$index]{main::key($num++,0,2,'running-in')} = $running_in; $data{$data_name}->[$index]{main::key($num++,0,2,'running-in')} = $running_in;
} }
$data{$data_name}->[$index]{main::key($num++,0,1,$self_name)} = &get_self_version(); }
$data{$data_name}->[$index]{main::key($num++,0,1,$self_name)} = get_self_version();
eval $end if $b_log; eval $end if $b_log;
return %data; return %data;
} }
@ -24938,7 +24997,6 @@ sub generate_system_data {
my $data_name = main::key($prefix++,1,0,'System'); my $data_name = main::key($prefix++,1,0,'System');
my ($desktop,$desktop_info,$desktop_key,$dm_key,$toolkit,$wm) = ('','','Desktop','dm','',''); my ($desktop,$desktop_info,$desktop_key,$dm_key,$toolkit,$wm) = ('','','Desktop','dm','','');
my (@desktop_data,$desktop_version); my (@desktop_data,$desktop_version);
my %data = ( my %data = (
$data_name => [{}], $data_name => [{}],
); );
@ -24992,13 +25050,15 @@ sub generate_system_data {
} }
} }
if (!$b_display || (!$desktop && $b_root)) { if (!$b_display || (!$desktop && $b_root)) {
my $tty = get_tty_number(); ShellData::tty_number() if !$loaded{'tty-number'};
my $tty = $client{'tty-number'};
if (!$desktop){ if (!$desktop){
$desktop_info = ''; $desktop_info = '';
} }
# it is defined, as '' # it is defined, as ''
if ($tty eq '' && $client{'console-irc'}){ if ($tty eq '' && $client{'console-irc'}){
$tty = get_tty_console_irc('vtnr'); ShellData::console_irc_tty() if !$loaded{'con-irc-tty'};
$tty = $client{'con-irc-tty'};
} }
$desktop = "tty $tty" if $tty ne ''; $desktop = "tty $tty" if $tty ne '';
$desktop_key = 'Console'; $desktop_key = 'Console';
@ -25028,7 +25088,7 @@ sub generate_system_data {
} }
} }
#if ($extra > 2 && $desktop_key ne 'Console'){ #if ($extra > 2 && $desktop_key ne 'Console'){
# my $tty = get_tty_number(); # my $tty = ShellData::tty_number() if !$loaded{'tty-number'};
# $data{$data_name}->[$index]{main::key($num++,0,1,'vc')} = $tty if $tty ne ''; # $data{$data_name}->[$index]{main::key($num++,0,1,'vc')} = $tty if $tty ne '';
#} #}
my $distro_key = ($bsd_type) ? 'OS': 'Distro'; my $distro_key = ($bsd_type) ? 'OS': 'Distro';

11
inxi.1
View file

@ -1,4 +1,4 @@
.TH INXI 1 "2021\-03\-15" inxi "inxi manual" .TH INXI 1 "2021\-03\-17" inxi "inxi manual"
.SH NAME .SH NAME
inxi \- Command line system information script for console and IRC inxi \- Command line system information script for console and IRC
@ -717,11 +717,11 @@ USB (\fB\-J\fR); triggers \fB\-xx\fR extra data option.
.TP .TP
.B \-v 7 .B \-v 7
\- Adds network IP data (\fB\-i\fR), forced bluetooth (\fB\-E\fR), \- Adds network IP data (\fB\-i\fR), forced bluetooth (\fB\-E\fR),
RAID (\fB\-R\fR); triggers \fB\-xxx\fR Logical (\fB\-L\fR), RAID (\fB\-R\fR); triggers \fB\-xxx\fR
.TP .TP
.B \-v 8 .B \-v 8
\- All system data available. Adds Logical (\fB\-L\fR), Repos (\fB\-r\fR), \- All system data available. Adds Repos (\fB\-r\fR),
PCI slots (\fB\-\-slots\fR), processes (\fB\-tcm\fR), admin (\fB\-\-admin\fR). PCI slots (\fB\-\-slots\fR), processes (\fB\-tcm\fR), admin (\fB\-\-admin\fR).
Useful for testing output and to see what data you can get from your system. Useful for testing output and to see what data you can get from your system.
@ -1316,8 +1316,9 @@ lxpanel, xfce4\-panel, lxqt\-panel, tint2, cairo-dock, trayer, and many others.
\- Adds (if present), display manager (\fBdm\fR) version number. \- Adds (if present), display manager (\fBdm\fR) version number.
\- Adds (if Linux, systemd, and in display), virtual terminal (\fBvt\fR) number. \- Adds (if available, and in display), virtual terminal (\fBvt\fR) number.
These are the same as \fBctrl+alt+F[x]\fR numbers usually. These are the same as \fBctrl+alt+F[x]\fR numbers usually. Some systems
have this, some don't, it varies.
.TP .TP
.B \-xxx \-w\fR,\fB \-W\fR .B \-xxx \-w\fR,\fB \-W\fR

View file

@ -1,3 +1,75 @@
=====================================================================================
Version: 3.3.03
Patch: 00
Date: 2021-03-17
-----------------------------------
Changes:
-----------------------------------
Bugs!! Fixes! Spring cleaning!
Because these are either newly created, or newly discovered, bugs,
this release was pushed as early as possible to get them fixed asap.
BUGS:
1. Desktop: Lumina detection had a syntax error which made it not work.
This has been broken for a while.
2. Logical: if not root, and if LUKS / bcache detected, failed to load
proc_partitions, which generates error on --logical --admin since the
required components data was not loaded. This was an oversight.
3. The 3.3.02 ShellData refactor created a bug for console IRC, showed
shell, not irc client, name, and set default shell data which also
showed.
4. Console IRC tty: there was also an older bug that made -S, -G
not work consistently, and there were errors that had been missed
for many years in that logic. These should all be corrected, console
irc out of display, or in display as root, should now show tty info,
tty size in -G.
FIXES:
1. Memory: restored $bsd_type block on /proc/meminfo and force NetBSD
to use a corrected vmstat. This leaves that block of logic to correct
the NetBSD oddities in meminfo, but it may fix future isses that popup.
2. -Sxxx man page item incorrectly said XDG_VTNR was systemd/linux, it's
not, it's various things, GhostBSD has it, for example. See what you get
for believing what people say!
3. Logical: added in N/A for null maj-min in --logical report. While
bug 2 triggered those errors, there could be future cases where maj-min
are null, like BSD lvm data etc.
ENHANCEMENTS:
1. Going along with Fix 1, added '--force meminfo' in case you really want that.
2. Distro: System Base: Added TrueNAS detection.
3. Package Data: Added mport [MidnightBSD] type. That requires root to run
for some odd reason, so won't see the best output if not root.
CHANGES:
1. Moved logical to -v7 from -v8, it's stable enough now.
CODE CHANGES:
1. Moved get_tty_number and get_tty_console_irc to ShellData:tty_number
and ShellData::tty_console_irc.
ShellData::tty_number was being loaded several times, added
$loaded{'tty-number'} test, and made client{'tty-number'} to store value.
tty_console_irc changed to console_irc_tty, which is what it gets, removed
hacks and made it load once and store result in client hash.
2. Optimization: retested sub vs package::method and they run at exactly
the same time, give or take, so moving more stuff into packages to make
it easier to maintain.
-----------------------------------
-- Harald Hope - Wed, 17 Mar 2021 19:36:39 -0700
===================================================================================== =====================================================================================
Version: 3.3.02 Version: 3.3.02
Patch: 00 Patch: 00