mirror of
https://github.com/smxi/inxi.git
synced 2024-11-17 00:31:19 +00:00
Version update. Redid -v options totally. Added -v 6 for full partition and unmounted partition output.
Adjusted the 2-5 options to include the various new features that have been added recently. Got rid of the entire old way of using verbosity level numbers internally in the script to trigger events, now all those printout triggers are done via clearly named global switch variables which are set in the initial Option selector function only. This should not make any particular difference to users, but it makes it easier to read the printout logic code, and to see what full/basic/verbosity level output actually is going to do. Also changed -d to -b, and added an error handler to -d showing it's been deprecated. -d will be needed in the future for advanced -D data, probably cd/dvd etc, and I want to keep the consistency, as much as possible, that is, m will be advanced M data, p is advanced P, n is advanced N, and so on. I know this breaks some people's habits, but I think with the deprecated option warning/error, it should be fine, and it's best to get this done now than to wait until inxi actually is going to use the -d advanced disk option. Ok, that's it, just basically a code clean up version.
This commit is contained in:
parent
2bd19db6ea
commit
ecb7d4cdb8
121
inxi
121
inxi
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
########################################################################
|
||||
#### Script Name: inxi
|
||||
#### version: 1.6.4
|
||||
#### version: 1.6.5
|
||||
#### Date: June 9 2011
|
||||
#### Patch Number: 00
|
||||
########################################################################
|
||||
|
@ -241,7 +241,10 @@ B_SCRIPT_UP='false'
|
|||
B_SHOW_ADVANCED_NETWORK='false'
|
||||
# Show sound card data
|
||||
B_SHOW_AUDIO='false'
|
||||
B_SHOW_BASIC_CPU='false'
|
||||
B_SHOW_BASIC_DISK='false'
|
||||
B_SHOW_CPU='false'
|
||||
B_SHOW_DISK_TOTAL='false'
|
||||
B_SHOW_DISK='false'
|
||||
# Show full hard disk output
|
||||
B_SHOW_FULL_HDD='false'
|
||||
|
@ -252,7 +255,7 @@ B_SHOW_HOST='true'
|
|||
B_SHOW_INFO='false'
|
||||
B_SHOW_IP='false'
|
||||
B_SHOW_LABELS='false'
|
||||
B_SHOW_MACHINE_DATA='false'
|
||||
B_SHOW_MACHINE='false'
|
||||
B_SHOW_NETWORK='false'
|
||||
# either -v > 3 or -P will show partitions
|
||||
B_SHOW_PARTITIONS='false'
|
||||
|
@ -360,7 +363,7 @@ SHOW_IRC=2
|
|||
# Verbosity level defaults to 0, this can also be set with -v0, -v2, -v3, etc as a parameter.
|
||||
VERBOSITY_LEVEL=0
|
||||
# Supported number of verbosity levels, including 0
|
||||
VERBOSITY_LEVELS=5
|
||||
VERBOSITY_LEVELS=6
|
||||
|
||||
# Clear nullglob, because it creates unpredictable situations with IFS=$'\n' ARR=($VAR) IFS="$ORIGINAL_IFS"
|
||||
# type constructs. Stuff like [rev a1] is now seen as a glob expansion pattern, and fails, and
|
||||
|
@ -1107,6 +1110,9 @@ error_handler()
|
|||
19)
|
||||
error_message="$2 downloaded but reports error on execution. Unable to continue."
|
||||
;;
|
||||
20)
|
||||
error_message="The option you selected has been deprecated. $2\nSee the -h (help) menu for currently supported options."
|
||||
;;
|
||||
*) error_message="error unknown: $@"
|
||||
set -- 99
|
||||
;;
|
||||
|
@ -1516,13 +1522,21 @@ get_parameters()
|
|||
exit 0
|
||||
# the short form only runs if no args output args are used
|
||||
# no need to run through these if there are no args
|
||||
# reserved for future use: -g for extra Graphics; -m for extra Machine; -d for extra Disk
|
||||
elif [[ -n $1 ]];then
|
||||
while getopts Ac:CdDfFGhHiIlMnNopPrsSt:uv:VxzZ%@:${update_flags} opt
|
||||
while getopts Abc:CdDfFGhHiIlMnNopPrsSt:uv:VxzZ%@:${update_flags} opt
|
||||
do
|
||||
case $opt in
|
||||
A) B_SHOW_AUDIO='true'
|
||||
use_short='false'
|
||||
;;
|
||||
b) use_short='false'
|
||||
B_SHOW_BASIC_CPU='true'
|
||||
B_SHOW_DISK_TOTAL='true'
|
||||
B_SHOW_GRAPHICS='true'
|
||||
B_SHOW_INFO='true'
|
||||
B_SHOW_SYSTEM='true'
|
||||
;;
|
||||
c) if [[ -n $( grep -E '^[0-9][0-9]?$' <<< $OPTARG ) ]];then
|
||||
case $OPTARG in
|
||||
99)
|
||||
|
@ -1565,8 +1579,7 @@ get_parameters()
|
|||
C) B_SHOW_CPU='true'
|
||||
use_short='false'
|
||||
;;
|
||||
d) VERBOSITY_LEVEL=1
|
||||
use_short='false'
|
||||
d) error_handler 20 "-d has been replaced by -b"
|
||||
;;
|
||||
D) B_SHOW_DISK='true'
|
||||
use_short='false'
|
||||
|
@ -1575,13 +1588,18 @@ get_parameters()
|
|||
B_CPU_FLAGS_FULL='true'
|
||||
use_short='false'
|
||||
;;
|
||||
F) VERBOSITY_LEVEL=$VERBOSITY_LEVELS
|
||||
B_EXTRA_DATA='true'
|
||||
F) B_EXTRA_DATA='true'
|
||||
B_SHOW_ADVANCED_NETWORK='true'
|
||||
B_SHOW_AUDIO='true'
|
||||
B_SHOW_CPU='true'
|
||||
B_SHOW_DISK='true'
|
||||
B_SHOW_MACHINE_DATA='true'
|
||||
B_SHOW_GRAPHICS='true'
|
||||
B_SHOW_INFO='true'
|
||||
B_SHOW_MACHINE='true'
|
||||
B_SHOW_NETWORK='true'
|
||||
B_SHOW_PARTITIONS='true'
|
||||
B_SHOW_SENSORS='true'
|
||||
B_SHOW_SYSTEM='true'
|
||||
use_short='false'
|
||||
;;
|
||||
G) B_SHOW_GRAPHICS='true'
|
||||
|
@ -1599,7 +1617,7 @@ get_parameters()
|
|||
B_SHOW_PARTITIONS='true'
|
||||
use_short='false'
|
||||
;;
|
||||
M) B_SHOW_MACHINE_DATA='true'
|
||||
M) B_SHOW_MACHINE='true'
|
||||
use_short='false'
|
||||
;;
|
||||
n) B_SHOW_ADVANCED_NETWORK='true'
|
||||
|
@ -1622,7 +1640,6 @@ get_parameters()
|
|||
r) B_SHOW_REPOS='true'
|
||||
use_short='false'
|
||||
;;
|
||||
|
||||
s) B_SHOW_SENSORS='true'
|
||||
use_short='false'
|
||||
;;
|
||||
|
@ -1649,9 +1666,37 @@ get_parameters()
|
|||
use_short='false'
|
||||
;;
|
||||
v) if [[ -n $( grep -E "^[0-9][0-9]?$" <<< $OPTARG ) && $OPTARG -le $VERBOSITY_LEVELS ]];then
|
||||
VERBOSITY_LEVEL="$OPTARG"
|
||||
if [[ $OPTARG -gt 0 ]];then
|
||||
if [[ $OPTARG -ge 1 ]];then
|
||||
use_short='false'
|
||||
B_SHOW_BASIC_CPU='true'
|
||||
B_SHOW_DISK_TOTAL='true'
|
||||
B_SHOW_GRAPHICS='true'
|
||||
B_SHOW_INFO='true'
|
||||
B_SHOW_SYSTEM='true'
|
||||
fi
|
||||
if [[ $OPTARG -ge 2 ]];then
|
||||
B_SHOW_BASIC_DISK='true'
|
||||
B_SHOW_MACHINE='true'
|
||||
B_SHOW_NETWORK='true'
|
||||
fi
|
||||
if [[ $OPTARG -ge 3 ]];then
|
||||
B_SHOW_ADVANCED_NETWORK='true'
|
||||
B_SHOW_CPU='true'
|
||||
B_EXTRA_DATA='true'
|
||||
fi
|
||||
if [[ $OPTARG -ge 4 ]];then
|
||||
B_SHOW_DISK='true'
|
||||
B_SHOW_PARTITIONS='true'
|
||||
fi
|
||||
if [[ $OPTARG -ge 5 ]];then
|
||||
B_SHOW_AUDIO='true'
|
||||
B_SHOW_SENSORS='true'
|
||||
B_SHOW_LABELS='true'
|
||||
B_SHOW_UUIDS='true'
|
||||
fi
|
||||
if [[ $OPTARG -ge 6 ]];then
|
||||
B_SHOW_PARTITIONS_FULL='true'
|
||||
B_SHOW_UNMOUNTED_PARTITIONS='true'
|
||||
fi
|
||||
else
|
||||
error_handler 4 "$OPTARG"
|
||||
|
@ -1785,17 +1830,18 @@ show_options()
|
|||
exit 1
|
||||
fi
|
||||
print_screen_output "$SCRIPT_NAME supports the following options. You can combine them, or list them"
|
||||
print_screen_output "one by one: Examples: $SCRIPT_NAME -v4 -c6 OR $SCRIPT_NAME -dDc 6"
|
||||
print_screen_output "one by one: Examples: $SCRIPT_NAME -v4 -c6 OR $SCRIPT_NAME -bDc 6"
|
||||
print_screen_output " "
|
||||
print_screen_output "If you start $SCRIPT_NAME with no arguments, it will show the short form."
|
||||
print_screen_output "The following options if used without -d or -v will show just the complete line(s):"
|
||||
print_screen_output "The following options if used without -F, -b, or -v will show just the complete line(s):"
|
||||
print_screen_output "A,C,D,G,I,M,N,P,S,f,i,n,o,p,l,u,r,s,t - you can use these alone or together to show"
|
||||
print_screen_output "just the line(s) you want to see."
|
||||
print_screen_output "If you use them with a -v level (or -d), it will show the full output for that line "
|
||||
print_screen_output "If you use them with a -v level (or -b), it will show the full output for that line "
|
||||
print_screen_output "along with the output for the chosen verbosity level."
|
||||
print_screen_output "- - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
|
||||
print_screen_output "Output Control Options:"
|
||||
print_screen_output "-A Show Audio/sound card information."
|
||||
print_screen_output "-b Shows basic output, short form (previously -d). Same as: $SCRIPT_NAME -v 1"
|
||||
print_screen_output "-c Available color schemes. Scheme number is required. Color selectors run a color selector option"
|
||||
print_screen_output " prior to $SCRIPT_NAME starting which lets you set the config file value for the selection."
|
||||
print_screen_output " Supported color schemes: 0-$color_scheme_count Example: $SCRIPT_NAME -c 11"
|
||||
|
@ -1807,7 +1853,6 @@ show_options()
|
|||
print_screen_output " 98 - Console IRC not in X"
|
||||
print_screen_output " 99 - Global - Overrides/removes all settings. Setting specific removes global."
|
||||
print_screen_output "-C Show full CPU output, including per CPU clockspeed."
|
||||
print_screen_output "-d Default output verbosity level, same as: $SCRIPT_NAME -v 1"
|
||||
print_screen_output "-D Show full hard Disk info, not only model, ie: /dev/sda ST380817AS 80.0GB."
|
||||
print_screen_output "-f Show all cpu flags used, not just the short list. Not shown with -F to avoid spamming."
|
||||
print_screen_output "-F Show Full output for $SCRIPT_NAME. Does not show extra verbose options like -f -u -l -o -p -t"
|
||||
|
@ -1836,11 +1881,13 @@ show_options()
|
|||
print_screen_output "-v Script verbosity levels. Verbosity level number is required."
|
||||
print_screen_output " Supported levels: 0-${VERBOSITY_LEVELS} Example: $SCRIPT_NAME -v 4"
|
||||
print_screen_output " 0 - Short output, same as: $SCRIPT_NAME"
|
||||
print_screen_output " 1 - Basic verbose, same as: $SCRIPT_NAME -d"
|
||||
print_screen_output " 2 - Also show networking card data"
|
||||
print_screen_output " 3 - Also show hard disk names as detected."
|
||||
print_screen_output " 4 - Also show partition size/filled data for (if present):/, /home, /var/, /boot"
|
||||
print_screen_output " 5 - For multicore systems, also shows: per core clock speeds; audio card; full disk data."
|
||||
print_screen_output " 1 - Basic verbose, same as: $SCRIPT_NAME -b"
|
||||
print_screen_output " 2 - Adds networking card (-N), Machine (-M) data, and shows basic hard disk data (names only)."
|
||||
print_screen_output " 3 - Adds advanced CPU (-C), network (-n) data, and switches on -x advanced data option."
|
||||
print_screen_output " 4 - Adds partition size/filled data (-P) for (if present):/, /home, /var/, /boot"
|
||||
print_screen_output " Shows full disk data (-D)"
|
||||
print_screen_output " 5 - Adds audio card (-A); sensors (-s), partion label (-l) and UUID (-u)."
|
||||
print_screen_output " 6 - Adds full partition data (-p), unmounted partition data (-o)."
|
||||
print_screen_output "-x Show extra data (only works with verbose or line output, not short form): "
|
||||
print_screen_output " -C - bogomips on Cpu;"
|
||||
print_screen_output " -N -A - Adds version/port(s)/driver version (if available) for Network/Audio;"
|
||||
|
@ -5289,34 +5336,34 @@ print_it_out()
|
|||
print_short_data
|
||||
else
|
||||
Lspci_Data="$( get_lspci_data )"
|
||||
if [[ $VERBOSITY_LEVEL -ge 1 || $B_SHOW_SYSTEM == 'true' ]];then
|
||||
if [[ $B_SHOW_SYSTEM == 'true' ]];then
|
||||
print_system_data
|
||||
fi
|
||||
if [[ $B_SHOW_MACHINE_DATA == 'true' ]];then
|
||||
if [[ $B_SHOW_MACHINE == 'true' ]];then
|
||||
print_machine_data
|
||||
fi
|
||||
if [[ $VERBOSITY_LEVEL -ge 1 || $B_SHOW_CPU == 'true' ]];then
|
||||
if [[ $B_SHOW_BASIC_CPU == 'true' || $B_SHOW_CPU == 'true' ]];then
|
||||
print_cpu_data
|
||||
fi
|
||||
if [[ $VERBOSITY_LEVEL -ge 1 || $B_SHOW_GRAPHICS == 'true' ]];then
|
||||
if [[ $B_SHOW_GRAPHICS == 'true' ]];then
|
||||
print_gfx_data
|
||||
fi
|
||||
if [[ $VERBOSITY_LEVEL -ge 5 || $B_SHOW_AUDIO == 'true' ]];then
|
||||
if [[ $B_SHOW_AUDIO == 'true' ]];then
|
||||
print_audio_data
|
||||
fi
|
||||
if [[ $VERBOSITY_LEVEL -ge 2 || $B_SHOW_NETWORK == 'true' ]];then
|
||||
if [[ $B_SHOW_NETWORK == 'true' ]];then
|
||||
print_networking_data
|
||||
fi
|
||||
if [[ $VERBOSITY_LEVEL -ge 1 || $B_SHOW_DISK == 'true' ]];then
|
||||
if [[ $B_SHOW_DISK_TOTAL == 'true' || $B_SHOW_BASIC_DISK == 'true' || $B_SHOW_DISK == 'true' ]];then
|
||||
print_hard_disk_data
|
||||
fi
|
||||
if [[ $VERBOSITY_LEVEL -ge 4 || $B_SHOW_PARTITIONS == 'true' ]];then
|
||||
if [[ $B_SHOW_PARTITIONS == 'true' ]];then
|
||||
print_partition_data
|
||||
fi
|
||||
if [[ $B_SHOW_UNMOUNTED_PARTITIONS == 'true' ]];then
|
||||
print_unmounted_partition_data
|
||||
fi
|
||||
if [[ $VERBOSITY_LEVEL -ge 5 || $B_SHOW_SENSORS == 'true' ]];then
|
||||
if [[ $B_SHOW_SENSORS == 'true' ]];then
|
||||
print_sensors_data
|
||||
fi
|
||||
if [[ $B_SHOW_REPOS == 'true' ]];then
|
||||
|
@ -5325,7 +5372,7 @@ print_it_out()
|
|||
if [[ $B_SHOW_PS_CPU_DATA == 'true' || $B_SHOW_PS_MEM_DATA == 'true' ]];then
|
||||
print_ps_data
|
||||
fi
|
||||
if [[ $VERBOSITY_LEVEL -ge 1 || $B_SHOW_INFO == 'true' ]];then
|
||||
if [[ $B_SHOW_INFO == 'true' ]];then
|
||||
print_info_data
|
||||
fi
|
||||
fi
|
||||
|
@ -5580,7 +5627,7 @@ print_cpu_data()
|
|||
fi
|
||||
|
||||
cpu_data=$( create_print_line "CPU$cpc_plural:" "${C1}${cpu_data_string}${C2} ${a_cpu_working[0]}$model_plural (${cpu_type})" )
|
||||
if [[ $VERBOSITY_LEVEL -ge 3 || $B_SHOW_CPU == 'true' ]];then
|
||||
if [[ $B_SHOW_CPU == 'true' ]];then
|
||||
# update for multicore, bogomips x core count.
|
||||
if [[ $B_EXTRA_DATA == 'true' ]];then
|
||||
# if [[ $cpu_vendor != 'intel' ]];then
|
||||
|
@ -5605,7 +5652,7 @@ print_cpu_data()
|
|||
cpu_data="$cpu_data${C2} ${C1}cache${C2} $cpu_cache$cpu_flags$bmip_data${CN}"
|
||||
fi
|
||||
# we don't this printing out extra line unless > 1 cpu core
|
||||
if [[ ${#A_CPU_DATA[@]} -gt 2 ]] && [[ $B_SHOW_CPU == 'true' || $VERBOSITY_LEVEL -ge 5 ]];then
|
||||
if [[ ${#A_CPU_DATA[@]} -gt 2 && $B_SHOW_CPU == 'true' ]];then
|
||||
cpu_clock_speed='' # null < verbosity level 5
|
||||
else
|
||||
cpu_data="$cpu_data ${C1}clocked at${C2} ${a_cpu_working[1]} MHz${CN}"
|
||||
|
@ -5615,7 +5662,7 @@ print_cpu_data()
|
|||
print_screen_output "$cpu_data"
|
||||
|
||||
# we don't this printing out extra line unless > 1 cpu core
|
||||
if [[ ${#A_CPU_DATA[@]} -gt 2 ]] && [[ $B_SHOW_CPU == 'true' || $VERBOSITY_LEVEL -ge 5 ]];then
|
||||
if [[ ${#A_CPU_DATA[@]} -gt 2 && $B_SHOW_CPU == 'true' ]];then
|
||||
for (( i=0; i < ${#A_CPU_DATA[@]}-1; i++ ))
|
||||
do
|
||||
IFS=","
|
||||
|
@ -5862,7 +5909,7 @@ print_hard_disk_data()
|
|||
local hdd_capacity=${a_hdd_basic_working[0]}
|
||||
local hdd_used=${a_hdd_basic_working[1]}
|
||||
|
||||
if [[ $VERBOSITY_LEVEL -ge 3 || $B_SHOW_DISK == 'true' ]];then
|
||||
if [[ $B_SHOW_BASIC_DISK == 'true' || $B_SHOW_DISK == 'true' ]];then
|
||||
## note: the output part of this should be in the print hdd data function, not here
|
||||
get_hard_drive_data_advanced
|
||||
for (( i=0; i < ${#A_HDD_DATA[@]} - 1; i++ ))
|
||||
|
@ -5871,7 +5918,7 @@ print_hard_disk_data()
|
|||
IFS=","
|
||||
a_hdd_working=( ${A_HDD_DATA[i]} )
|
||||
IFS="$ORIGINAL_IFS"
|
||||
if [[ $B_SHOW_DISK == 'true' || $VERBOSITY_LEVEL -ge 5 ]];then
|
||||
if [[ $B_SHOW_DISK == 'true' ]];then
|
||||
if [[ -n ${a_hdd_working[3]} ]];then
|
||||
usb_data="${a_hdd_working[3]} "
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue