aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@ubuntu.com>2016-05-21 18:05:14 -0400
committerLibravatarUnit 193 <unit193@ubuntu.com>2016-05-21 18:05:14 -0400
commit4eee2649af2caf1829ee9d8520e93d4b12092d0a (patch)
tree3f5ac98227977632807f13b4969469388f2c1446
parent1904fde82e4912fde22afee0e6e1f23040ce8739 (diff)
downloadinxi-upstream/2.3.0.tar.bz2
inxi-upstream/2.3.0.tar.xz
inxi-upstream/2.3.0.tar.zst
Imported Upstream version 2.3.0upstream/2.3.0
-rwxr-xr-xinxi526
-rwxr-xr-xinxi.146
-rw-r--r--inxi.1.gzbin10080 -> 10601 bytes
-rwxr-xr-xinxi.changelog78
4 files changed, 615 insertions, 35 deletions
diff --git a/inxi b/inxi
index c6c237b..fc9550f 100755
--- a/inxi
+++ b/inxi
@@ -1,8 +1,8 @@
#!/usr/bin/env bash
########################################################################
#### Script Name: inxi
-#### Version: 2.2.35
-#### Date: 2016-02-29
+#### Version: 2.3.0
+#### Date: 2016-04-18
#### Patch Number: 00
########################################################################
#### SPECIAL THANKS
@@ -254,6 +254,7 @@ ORIGINAL_IFS="$IFS"
## Initialize
A_ALSA_DATA=''
A_AUDIO_DATA=''
+A_BATTERY_DATA=''
A_CMDL=''
A_CPU_CORE_DATA=''
A_CPU_DATA=''
@@ -334,6 +335,8 @@ B_SHOW_BASIC_RAID='false'
B_SHOW_BASIC_CPU='false'
B_SHOW_BASIC_DISK='false'
B_SHOW_BASIC_OPTICAL='false'
+B_SHOW_BATTERY='false'
+B_SHOW_BATTERY_FORCED='false'
B_SHOW_CPU='false'
B_SHOW_DISPLAY_DATA='false'
B_SHOW_DISK_TOTAL='false'
@@ -603,8 +606,21 @@ MAGENTA,YELLOW,NORMAL
RED,CYAN,NORMAL
RED,WHITE,NORMAL
BLUE,WHITE,NORMAL
+
+RED,BLUE,NORMAL
+RED,DBLUE,NORMAL
+BLACK,BLUE,NORMAL
+BLACK,DBLUE,NORMAL
+NORMAL,BLUE,NORMAL
+BLUE,MAGENTA,NORMAL
+DBLUE,MAGENTA,NORMAL
+BLACK,MAGENTA,NORMAL
+MAGENTA,BLUE,NORMAL
+MAGENTA,DBLUE,NORMAL
)
+#echo ${#A_COLOR_SCHEMES[@]};exit
+
# WARNING: In the main part below (search for 'KONVI')
# there's a check for Konversation-specific config files.
# Any one of these can override the above if inxi is run
@@ -697,7 +713,7 @@ main()
# note: this only works if it's run from inside konversation as a script builtin or something
# only do this if inxi has been started as a konversation script, otherwise bypass this
-# KONVI=3 ## for testing puroses
+ # KONVI=3 ## for testing puroses
if [[ $KONVI -eq 1 || $KONVI -eq 3 ]];then
if [[ $KONVI -eq 1 ]]; then ## dcop Konversation (ie 1.x < 1.2(qt3))
DCPORT="$1"
@@ -868,7 +884,7 @@ initialize_data()
else
# found a case of battery existing but having nothing in it on desktop mobo
# not all laptops show the first. /proc/acpi/battery is deprecated.
- if [[ -n $( ls /proc/acpi/battery 2>/dev/null ) || -e /sys/class/power_supply/BAT0/ ]];then
+ if [[ -n $( ls /proc/acpi/battery 2>/dev/null ) || -n $( ls /sys/class/power_supply/ 2>/dev/null ) ]];then
B_PORTABLE='true'
fi
fi
@@ -1221,7 +1237,7 @@ select_default_color_scheme()
# print_screen_output "You will see this message only one time per user account, unless you set preferences in: /etc/$SCRIPT_NAME.conf"
print_screen_output " "
fi
- print_lines_basic "0" "" "Because there is no way to know your $COLOR_SELECTION foreground/background colors, you can set your color preferences from color scheme option list below. 0 is no colors, 1 neutral. After these, there are 3 sets: 1-dark or light backgrounds; 2-light backgrounds; 3-dark backgrounds."
+ print_lines_basic "0" "" "Because there is no way to know your $COLOR_SELECTION foreground/background colors, you can set your color preferences from color scheme option list below. 0 is no colors, 1 neutral. After these, there are 4 sets: 1-dark or light backgrounds; 2-light backgrounds; 3-dark backgrounds; 4-miscellaneous."
if [[ $B_IRC == 'false' ]];then
print_lines_basic "0" "" "Please note that this will set the $COLOR_SELECTION preferences only for user: $(whoami)"
fi
@@ -1745,7 +1761,10 @@ debug_data_collector()
get_repo_data "$SCRIPT_DATA_DIR/$debug_data_dir"
if type -p shopt &>/dev/null;then
- shopt -s nullglob;a_distro_ids=(/etc/*[-_]{release,version});shopt -u nullglob;echo ${a_distro_ids[@]} &> $debug_data_dir/etc-distro-files.txt
+ shopt -s nullglob
+ a_distro_ids=(/etc/*[-_]{release,version})
+ shopt -u nullglob
+ echo ${a_distro_ids[@]} &> $debug_data_dir/etc-distro-files.txt
for distro_file in ${a_distro_ids[@]} /etc/issue
do
if [[ -f $distro_file ]];then
@@ -1800,6 +1819,17 @@ debug_data_collector()
else
touch $debug_data_dir/strings-absent
fi
+ local id_dir='/sys/class/power_supply/'
+ local ids=$( ls $id_dir 2>/dev/null )
+ if [[ -n $ids ]];then
+ for batid in $ids
+ do
+ cat $id_dir$batid'/uevent' &> $debug_data_dir/sys-power-supply-$batid.txt
+ done
+ else
+ touch $debug_data_dir/sys-power-supply-none
+ fi
+
# leaving this commented out to remind that some systems do not
# support strings --version, but will just simply hang at that command
# which you can duplicate by simply typing: strings then hitting enter, you will get hang.
@@ -2519,7 +2549,7 @@ get_parameters()
# 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 Abc:CdDfFGhHiIlmMnNopPrRsSt:uUv:V${weather_flag}xy:zZ%@:!: opt
+ while getopts AbBc:CdDfFGhHiIlmMnNopPrRsSt:uUv:V${weather_flag}xy:zZ%@:!: opt
do
case $opt in
A) B_SHOW_AUDIO='true'
@@ -2532,9 +2562,14 @@ get_parameters()
B_SHOW_GRAPHICS='true'
B_SHOW_INFO='true'
B_SHOW_MACHINE='true'
+ B_SHOW_BATTERY='true'
B_SHOW_NETWORK='true'
B_SHOW_SYSTEM='true'
;;
+ B) B_SHOW_BATTERY_FORCED='true'
+ B_SHOW_BATTERY='true'
+ use_short='false'
+ ;;
c) if [[ $OPTARG =~ ^[0-9][0-9]?$ ]];then
case $OPTARG in
99)
@@ -2598,6 +2633,7 @@ get_parameters()
B_SHOW_GRAPHICS='true'
B_SHOW_INFO='true'
B_SHOW_MACHINE='true'
+ B_SHOW_BATTERY='true'
B_SHOW_NETWORK='true'
B_SHOW_PARTITIONS='true'
B_SHOW_RAID='true'
@@ -2624,6 +2660,7 @@ get_parameters()
use_short='false'
;;
M) B_SHOW_MACHINE='true'
+ B_SHOW_BATTERY='true'
use_short='false'
;;
n) B_SHOW_ADVANCED_NETWORK='true'
@@ -2690,6 +2727,7 @@ get_parameters()
if [[ $OPTARG -ge 2 ]];then
B_SHOW_BASIC_DISK='true'
B_SHOW_BASIC_RAID='true'
+ B_SHOW_BATTERY='true'
B_SHOW_MACHINE='true'
B_SHOW_NETWORK='true'
fi
@@ -2934,11 +2972,12 @@ show_options()
# print_screen_output " "
print_lines_basic "0" "" "$SCRIPT_NAME supports the following options. You can combine them, or list them one by one. Examples: $SCRIPT_NAME^-v4^-c6 OR $SCRIPT_NAME^-bDc^6. If you start $SCRIPT_NAME with no arguments, it will show the short form."
print_screen_output " "
- print_lines_basic "0" "" "The following options if used without -F, -b, or -v will show just option line(s): A, C, D, G, I, M, N, P, R, S, f, i, m, n, o, p, l, u, r, s, t - you can use these alone or together to show just the line(s) you want to see. If you use them with -v^[level], -b or -F, it will show the full output for that line along with the output for the chosen verbosity level."
+ print_lines_basic "0" "" "The following options if used without -F, -b, or -v will show just option line(s): A, B, C, D, G, I, M, N, P, R, S, f, i, m, n, o, p, l, u, r, s, t - you can use these alone or together to show just the line(s) you want to see. If you use them with -v^[level], -b or -F, it will show the full output for that line along with the output for the chosen verbosity level."
print_screen_output "- - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
print_screen_output "Output Control Options:"
print_lines_basic "1" "-A" "Audio/sound card information."
- print_lines_basic "1" "-b" "Basic output, short form. Like $SCRIPT_NAME^-v^2, only minus hard disk names."
+ print_lines_basic "1" "-b" "Basic output, short form. Like $SCRIPT_NAME^-v^2, only minus hard disk names ."
+ print_lines_basic "1" "-B" "Battery info, shows charge, condition, plus extra information (if battery present)."
print_lines_basic "1" "-c" "Color schemes. Scheme number is required. Color selectors run a color selector option prior to $SCRIPT_NAME starting which lets you set the config file value for the selection."
print_lines_basic "1" "" "Supported color schemes: 0-$color_scheme_count Example:^$SCRIPT_NAME^-c^11"
print_lines_basic "1" "" "Color selectors for each type display (NOTE: irc and global only show safe color set):"
@@ -2978,8 +3017,8 @@ show_options()
print_lines_basic "1" "" "Supported levels: 0-$VERBOSITY_LEVELS Example: $SCRIPT_NAME^-v^4"
print_lines_basic "2" "0" "Short output, same as: $SCRIPT_NAME"
print_lines_basic "2" "1" "Basic verbose, -S + basic CPU + -G + basic Disk + -I."
- print_lines_basic "2" "2" "Networking card (-N), Machine (-M) data, shows basic hard disk data (names only), and, if present, basic raid (devices only, and if inactive, notes that). similar to: $SCRIPT_NAME^-b"
- print_lines_basic "2" "3" "Advanced CPU (-C), network (-n) data, and switches on -x advanced data option."
+ print_lines_basic "2" "2" "Networking card (-N), Machine (-M) data, if present, Battery (-B), basic hard disk data (names only), and, if present, basic raid (devices only, and if inactive, notes that). similar to: $SCRIPT_NAME^-b"
+ print_lines_basic "2" "3" "Advanced CPU (-C), battery, network (-n) data, and switches on -x advanced data option."
print_lines_basic "2" "4" "$partition_string_u size/filled data (-P) for (if present): /, /home, /var/, /boot. Shows full disk data (-D)."
print_lines_basic "2" "5" "Audio card (-A); sensors^(-s), memory/ram^(-m), $partition_string label^(-l) and UUID^(-u), short form of optical drives, standard raid data (-R)."
print_lines_basic "2" "6" "Full $partition_string (-p), unmounted $partition_string (-o), optical drive (-d), full raid; triggers -xx."
@@ -2991,6 +3030,7 @@ show_options()
print_lines_basic "1" "-W" "<location> Supported options for <location>: postal code; city, state/country; latitude, longitude. Only use if you want the weather somewhere other than the machine running $SCRIPT_NAME. Use only ascii characters, replace spaces in city/state/country names with '+'. Example:^$SCRIPT_NAME^-W^new+york,ny"
fi
print_lines_basic "1" "-x" "Adds the following extra data (only works with verbose or line output, not short form):"
+ print_lines_basic "2" "-B" "Vendor/model, status (if available)"
print_lines_basic "2" "-C" "CPU Flags, Bogomips on Cpu;"
print_lines_basic "2" "-d" "Extra optical drive data; adds rev version to optical drive."
print_lines_basic "2" "-D" "Hdd temp with disk data if you have hddtemp installed, if you are root OR if you have added to /etc/sudoers (sudo v. 1.7 or newer) Example:^<username>^ALL^=^NOPASSWD:^/usr/sbin/hddtemp"
@@ -3009,6 +3049,7 @@ show_options()
fi
print_lines_basic "1" "-xx" "Show extra, extra data (only works with verbose or line output, not short form):"
print_lines_basic "2" "-A" "Chip vendor:product ID for each audio device."
+ print_lines_basic "2" "-B" "serial number, voltage (if available)."
print_lines_basic "2" "-C" "Minimum CPU speed, if available."
print_lines_basic "2" "-D" "Disk serial number."
print_lines_basic "2" "-G" "Chip vendor:product ID for each video card."
@@ -3023,6 +3064,7 @@ show_options()
fi
print_lines_basic "2" "-@ 11-14" "Automatically uploads debugger data tar.gz file to ftp.techpatterns.com. EG: $SCRIPT_NAME^-xx@14"
print_lines_basic "1" "-xxx" "Show extra, extra, extra data (only works with verbose or line output, not short form):"
+ print_lines_basic "2" "-B" "chemistry, cycles, location (if available)."
print_lines_basic "2" "-m" "Width of memory bus, data and total (if present and greater than data); Detail, if present, for Type; module voltage, if available."
print_lines_basic "2" "-S" "Panel/shell information in desktop output, if in X (like gnome-shell, cinnamon, mate-panel)."
if [[ $B_ALLOW_WEATHER == 'true' ]];then
@@ -3958,6 +4000,233 @@ get_audio_alsa_data()
eval $LOGFE
}
+get_battery_data()
+{
+ eval $LOGFS
+ local a_temp='' id_file='' count=0
+ local id_dir='/sys/class/power_supply/'
+ local ids=$( ls $id_dir 2>/dev/null ) battery_file=''
+
+ # ids='BAT0 BAT1 BAT2'
+ if [[ -n $ids && $B_FORCE_DMIDECODE == 'false' ]];then
+ for idx in $ids
+ do
+ battery_file=$id_dir$idx'/uevent'
+ if [[ -r $battery_file ]];then
+ # echo $battery_file
+ count=$(( $count + 1 ))
+ IFS=$'\n'
+ battery_data=$(
+ gawk -F '=' '
+ BEGIN {
+ IGNORECASE=1
+ name=""
+ status=""
+ present=""
+ chemistry=""
+ cycles=""
+ voltage_min_design=""
+ voltage_now=""
+ power_now=""
+ charge_full_design=""
+ charge_full=""
+ charge_now=""
+ capacity=""
+ capacity_level=""
+ model=""
+ company=""
+ serial=""
+ of_orig=""
+ location=""
+ }
+ {
+ gsub(/'"$BAN_LIST_NORMAL"'|,|battery|unknown/, "", $2)
+ gsub(/^ +| +$/, "", $2)
+ }
+ $1 ~ /^POWER_SUPPLY_NAME$/ {
+ name=$NF
+ }
+ $1 ~ /^POWER_SUPPLY_STATUS$/ {
+ status=$NF
+ }
+ $1 ~ /^POWER_SUPPLY$/ {
+ present=$NF
+ }
+ $1 ~ /^POWER_SUPPLY_TECHNOLOGY$/ {
+ chemistry=$NF
+ }
+ $1 ~ /^POWER_SUPPLY_CYCLE_COUNT$/ {
+ cycles=$NF
+ }
+ $1 ~ /^POWER_SUPPLY_VOLTAGE_MIN_DESIGN$/ {
+ voltage_min_design = $NF / 1000000
+ voltage_min_design = sprintf( "%.1f", voltage_min_design )
+ }
+ $1 ~ /^POWER_SUPPLY_VOLTAGE_NOW$/ {
+ voltage_now = $NF / 1000000
+ voltage_now = sprintf( "%.1f", voltage_now )
+ }
+ $1 ~ /^POWER_SUPPLY_POWER_NOW$/ {
+ power_now=$NF
+ }
+ $1 ~ /^POWER_SUPPLY_ENERGY_FULL_DESIGN$/ {
+ charge_full_design = $NF / 1000000
+ }
+ $1 ~ /^POWER_SUPPLY_ENERGY_FULL$/ {
+ charge_full = $NF / 1000000
+ }
+ $1 ~ /^POWER_SUPPLY_ENERGY_NOW$/ {
+ charge_now = $NF / 1000000
+ charge_now = sprintf( "%.1f", charge_now )
+ }
+ $1 ~ /^POWER_SUPPLY_CHARGE_FULL_DESIGN$/ {
+ charge_full_design = $NF / 100000
+ }
+ $1 ~ /^POWER_SUPPLY_CHARGE_FULL$/ {
+ charge_full = $NF / 100000
+ }
+ $1 ~ /^POWER_SUPPLY_CHARGE_NOW$/ {
+ charge_now = $NF / 100000
+ }
+ $1 ~ /^POWER_SUPPLY_CAPACITY$/ {
+ if ( $NF != "" ){
+ capacity=$NF "%"
+ }
+ }
+ $1 ~ /^POWER_SUPPLY_CAPACITY_LEVEL$/ {
+ capacity_level=$NF
+ }
+ $1 ~ /^POWER_SUPPLY_MODEL_NAME$/ {
+ model=$NF
+ }
+ $1 ~ /^POWER_SUPPLY_MANUFACTURER$/ {
+ company=$NF
+ }
+ $1 ~ /^POWER_SUPPLY_SERIAL_NUMBER$/ {
+ serial=$NF
+ }
+ END {
+ if (charge_now != "" && charge_full != "" ){
+ capacity = 100*charge_now/charge_full
+ capacity = sprintf( "%.1f%", capacity )
+ }
+ if (charge_full_design != "" && charge_full != "" ){
+ of_orig=100*charge_full/charge_full_design
+ of_orig = sprintf( "%.0f%", of_orig )
+ }
+ if (charge_now != "" ){
+ charge_now = sprintf( "%.1f", charge_now )
+ }
+ if (charge_full_design != "" ){
+ charge_full_design = sprintf( "%.1f", charge_full_design )
+ }
+ if ( charge_full != "" ){
+ charge_full = sprintf( "%.1f", charge_full )
+ }
+ entry = name "," status "," present "," chemistry "," cycles "," voltage_min_design "," voltage_now ","
+ entry = entry power_now "," charge_full_design "," charge_full "," charge_now "," capacity ","
+ entry = entry capacity_level "," of_orig "," model "," company "," serial "," location
+ print entry
+ }' < $battery_file )
+ # <<< "$data" )
+ # < $battery_file )
+ A_BATTERY_DATA[$count]=$battery_data
+ IFS="$ORIGINAL_IFS"
+ fi
+ done
+ elif [[ $B_FORCE_DMIDECODE == 'true' ]] || [[ ! -d $id_dir && -z $ids ]];then
+ get_dmidecode_data
+ if [[ -n $DMIDECODE_DATA ]];then
+ if [[ $DMIDECODE_DATA == 'dmidecode-error-'* ]];then
+ A_BATTERY_DATA[0]=$DMIDECODE_DATA
+ # please note: only dmidecode version 2.11 or newer supports consistently the -s flag
+ else
+ IFS=$'\n'
+ # NOTE: this logic has a flaw, which is multiple batteries, which won't work without
+ # gawk arrays, but sorry, too much of a pain given how little useful data from dmidecode
+ A_BATTERY_DATA=( $( gawk -F ':' '
+ BEGIN {
+ IGNORECASE=1
+ name=""
+ status=""
+ present=""
+ chemistry=""
+ cycles=""
+ voltage_min_design=""
+ voltage_now=""
+ power_now=""
+ charge_full_design=""
+ charge_full=""
+ charge_now=""
+ capacity=""
+ capacity_level=""
+ model=""
+ company=""
+ serial=""
+ of_orig=""
+ location=""
+ bItemFound="false"
+ }
+ {
+ gsub(/'"$BAN_LIST_NORMAL"'|,|battery|unknown/, "", $2)
+ gsub(/^ +| +$/, "", $1)
+ gsub(/^ +| +$/, "", $2)
+ }
+ /^Portable Battery/ {
+ while ( getline && !/^$/ ) {
+ if ( $1 ~ /^Location/ ) { location=$2 }
+ if ( $1 ~ /^Manufacturer/ ) { company=$2 }
+ if ( $1 ~ /^Serial/ ) { serial=$2 }
+ if ( $1 ~ /^Name/ ) { model=$2 }
+ if ( $1 ~ /^Design Capacity/ ) {
+ sub(/^[[:space:]]*mwh/, "", $2)
+ charge_full_design = $NF / 1000
+ charge_full_design = sprintf( "%.1f", charge_full_design )
+ }
+ if ( $1 ~ /^Design Voltage/ ) {
+ sub(/^[[:space:]]*mv/, "", $2)
+ voltage_min_design = $NF / 1000
+ voltage_min_design = sprintf( "%.1f", voltage_min_design )
+ }
+ if ( $1 ~ /^SBDS Chemistry/ ) { chemistry=$2 }
+ }
+ testString=company serial model charge_full_design voltage_min_design
+ if ( testString != "" ) {
+ bItemFound="true"
+ exit # exit loop, we are not handling > 1 batteries
+ }
+ }
+ END {
+ if ( bItemFound == "true" ) {
+ name="BAT-1"
+ if (charge_now != "" && charge_full != "" ){
+ capacity = 100*charge_now/charge_full
+ capacity = sprintf( "%.1f%", capacity )
+ }
+ if (charge_full_design != "" && charge_full != "" ){
+ of_orig=100*charge_full/charge_full_design
+ of_orig = sprintf( "%.0f%", of_orig )
+ }
+ entry = name "," status "," present "," chemistry "," cycles "," voltage_min_design "," voltage_now ","
+ entry = entry power_now "," charge_full_design "," charge_full "," charge_now "," capacity ","
+ entry = entry capacity_level "," of_orig "," model "," company "," serial "," location
+ print entry
+ }
+ }' <<< "$DMIDECODE_DATA" ) )
+ IFS="$ORIGINAL_IFS"
+ fi
+ fi
+ fi
+ # echo $array_string
+
+ #echo ${#A_BATTERY_DATA[@]}
+ a_temp=${A_BATTERY_DATA[@]}
+
+ # echo $a_temp
+ log_function_data "A_BATTERY_DATA: $a_temp"
+ eval $LOGFE
+}
+
## create A_CPU_CORE_DATA, currently with two values: integer core count; core string text
## return value cpu core count string, this helps resolve the multi redundant lines of old style output
get_cpu_core_count()
@@ -5088,7 +5357,7 @@ get_display_manager()
get_distro_data()
{
eval $LOGFS
- local i='' j='' distro='' distro_file='' a_distro_glob='' a_temp=''
+ local i='' j='' distro='' distro_file='' a_distro_glob='' a_temp='' b_osr='false'
# may need modification if archbsd / debian can be id'ed with /etc files
if [[ -n $BSD_TYPE ]];then
@@ -5161,6 +5430,7 @@ get_distro_data()
distro=$( get_distro_lsb_os_release_data 'lsb-file' )
elif [[ $distro_file == 'os-release' ]];then
distro=$( get_distro_lsb_os_release_data 'os-release-file' )
+ b_osr='true'
# then if the distro id file was found and it's not in the exluded primary distro file list, read it
elif [[ -n $distro_file && -s /etc/$distro_file && " $DISTROS_EXCLUDE_LIST " != *" $distro_file "* ]];then
# new opensuse uses os-release, but older ones may have a similar syntax, so just use the first line
@@ -5174,9 +5444,12 @@ get_distro_data()
fi
# otherwise try the default debian/ubuntu /etc/issue file
elif [[ -f /etc/issue ]];then
- # lsb gives more manageable and accurate output than issue, but mint should use issue for now
+ # os-release/lsb gives more manageable and accurate output than issue, but mint should use issue for now
# some bashism, boolean must be in parenthesis to work correctly, ie [[ $(boolean) ]] not [[ $boolean ]]
- if [[ $B_LSB_FILE == 'true' ]] && [[ -z $( grep -i 'mint' /etc/issue ) ]];then
+ if [[ $B_OS_RELEASE_FILE == 'true' ]] && [[ -z $( grep -i 'mint' /etc/issue ) ]];then
+ distro=$( get_distro_lsb_os_release_data 'os-release-file' )
+ b_osr='true'
+ elif [[ $B_LSB_FILE == 'true' ]] && [[ -z $( grep -i 'mint' /etc/issue ) ]];then
distro=$( get_distro_lsb_os_release_data 'lsb-file' )
else
distro=$( gawk '
@@ -5199,20 +5472,28 @@ get_distro_data()
fi
fi
fi
-
+ # a final check. If a long value, before assigning the debugger output, if os-release
+ # exists then let's use that if it wasn't tried already. Maybe that will be better.
if [[ ${#distro} -gt 80 ]] && [[ $B_HANDLE_CORRUPT_DATA != 'true' ]];then
- distro="${RED}/etc/$distro_file corrupted, use -% to override${NORMAL}"
+ if [[ $B_OS_RELEASE_FILE == 'true' && $b_osr == 'false' ]];then
+ distro=$( get_distro_lsb_os_release_data 'os-release-file' )
+ fi
+ if [[ ${#distro} -gt 80 ]];then
+ distro="${RED}/etc/$distro_file corrupted, use -% to override${NORMAL}"
+ fi
fi
## note: would like to actually understand the method even if it's not used
# : ${distro:=Unknown distro o_O}
## test for /etc/lsb-release as a backup in case of failure, in cases where > one version/release file
## were found but the above resulted in null distro value
- if [[ -z $distro ]] && [[ $B_LSB_FILE == 'true' ]];then
- distro=$( get_distro_lsb_os_release_data 'lsb-file' )
- fi
+ # Because os-release is now more common, we'll test for it first.
if [[ -z $distro ]] && [[ $B_OS_RELEASE_FILE == 'true' ]];then
distro=$( get_distro_lsb_os_release_data 'os-release-file' )
fi
+ if [[ -z $distro ]] && [[ $B_LSB_FILE == 'true' ]];then
+ distro=$( get_distro_lsb_os_release_data 'lsb-file' )
+ fi
+
# now some final null tries
if [[ -z $distro ]];then
# if the file was null but present, which can happen in some cases, then use the file name itself to
@@ -5412,7 +5693,7 @@ get_dmidecode_data()
fi
# these tests first, because bsd error messages like this (note how many : are in the string)
# inxi: line 4928: /usr/local/sbin/dmidecode: Permission denied
- if [[ ${#dmiData} -lt 100 ]];then
+ if [[ ${#dmiData} -lt 200 ]];then
if [[ -z ${dmiData/*Permission denied*/} ]];then
# if [[ -n $( grep -i 'Permission denied' <<< "$dmiData" ) ]];then
DMIDECODE_DATA='dmidecode-error-requires-root'
@@ -7862,9 +8143,9 @@ get_partition_data()
if [[ $( grep -cs '[[:space:]]/$' <<< "$main_partition_data" ) -gt 1 ]];then
main_partition_data="$( grep -vs '^rootfs' <<< "$main_partition_data" )"
fi
+ # echo "$main_partition_data"
log_function_data 'raw' "main_partition_data_post_rootfs:\n$main_partition_data\n\nswap_data:\n$swap_data"
IFS=$'\n'
- # sample line: /dev/sda2 ext3 15G 8.9G 4.9G 65% /home
# $NF = partition name; $(NF - 4) = partition size; $(NF - 3) = used, in gB; $(NF - 1) = percent used
## note: by subtracting from the last field number NF, we avoid a subtle issue with LVM df output, where if
## the first field is too long, it will occupy its own line, this way we are getting only the needed data
@@ -7878,8 +8159,9 @@ get_partition_data()
# skipping these file systems because bsds do not support df --exclude-type=<fstype>
# note that using $1 to handle older bsd df, which do not support -T. This will not be reliable but we will see
( bsdType != "" ) {
- # skip if non disk/partition, or if raid primary id, which will not have a / in it
- if ( $1 ~ /^(aufs|devfs|devtmpfs|fdescfs|iso9660|linprocfs|procfs|squashfs|sysfs|tmpfs|type|unionfs)$/ ||
+ # skip if non disk/partition, or if raid primary id, which will not have a / in it.
+ # Note: kfreebsd uses /sys, not sysfs, is this a bug or expected behavior?
+ if ( $1 ~ /^(aufs|devfs|devtmpfs|fdescfs|iso9660|linprocfs|procfs|squashfs|\/sys|sysfs|tmpfs|type|unionfs)$/ ||
( $1 ~ /^([^\/]+)$/ && $1 !~ /^ROOT/ ) ) {
# note use next, not getline or it does not work right
next
@@ -7965,7 +8247,6 @@ get_partition_data()
print $(NF - 2) " " $(NF - 1) " " $NF "," $(NF - 6) "," $(NF - 5) "," $(NF - 3) ",secondary," fileSystem "," devBase
}
}' )
-
# now add the swap partition data, don't want to show swap files, just partitions,
# though this can include /dev/ramzswap0. Note: you can also use /proc/swaps for this
# data, it's the same exact output as swapon -s
@@ -8068,7 +8349,7 @@ get_partition_data()
fi
done
a_temp=${A_PARTITION_DATA[@]}
- # echo $a_temp
+ # echo $a_temp;exit
log_function_data "2: A_PARTITION_DATA:\n$a_temp"
if [[ $B_SHOW_LABELS == 'true' || $B_SHOW_UUIDS == 'true' ]];then
get_partition_data_advanced
@@ -11142,6 +11423,9 @@ print_it_out()
if [[ $B_SHOW_MACHINE == 'true' ]];then
print_machine_data
fi
+ if [[ $B_SHOW_BATTERY == 'true' ]];then
+ print_battery_data
+ fi
if [[ $B_SHOW_BASIC_CPU == 'true' || $B_SHOW_CPU == 'true' ]];then
print_cpu_data
fi
@@ -11479,6 +11763,188 @@ print_audio_data()
eval $LOGFE
}
+print_battery_data()
+{
+ eval $LOGFS
+ local line_starter='Battery' print_data=''
+ get_battery_data
+ if [[ -n ${A_BATTERY_DATA[@]} ]];then
+ local battery_data='' battery_string=''
+ local present='' chemistry='' cycles='' voltage_min_design='' voltage_now=''
+ local power_now='' charge_full_design='' charge_full='' charge_now='' capacity=''
+ local capacity_level='' model='' company='' serial='' of_orig='' model='' condition=''
+ local power=''
+
+ # echo ${A_BATTERY_DATA[@]}
+ for (( i=0; i< ${#A_BATTERY_DATA[@]}; i++ ))
+ do
+ battery_data=''
+ print_data=''
+ battery_string=''
+ charge=''
+ model=''
+ condition=''
+ voltage=''
+
+ name=''
+ status=''
+ present=''
+ chemistry=''
+ cycles=''
+ voltage_min_design=''
+ voltage_now=''
+ power_now=''
+ charge_full_design=''
+ charge_full=''
+ charge_now=''
+ capacity=''
+ capacity_level=''
+ of_orig=''
+ model=''
+ company=''
+ serial=''
+ location='' # dmidecode only
+ IFS=","
+ a_battery_working=( ${A_BATTERY_DATA[i]} )
+ IFS="$ORIGINAL_IFS"
+ bat_id="$(( $i + 1 ))"
+
+ if [[ -n ${a_battery_working[10]} ]];then
+ charge="${a_battery_working[10]} Wh "
+ fi
+ if [[ -n ${a_battery_working[11]} ]];then
+ charge="$charge${a_battery_working[11]} "
+ fi
+ if [[ $charge == '' ]];then
+ charge='N/A '
+ fi
+ charge="${C1}charge$SEP3${C2} $charge"
+ if [[ -n ${a_battery_working[9]} ]];then
+ condition="${a_battery_working[9]}"
+ else
+ condition='NA'
+ fi
+ if [[ -n ${a_battery_working[8]} ]];then
+ condition="$condition/${a_battery_working[8]} Wh "
+ else
+ condition="$condition/NA Wh "
+ fi
+ if [[ -n ${a_battery_working[13]} ]];then
+ condition="$condition(${a_battery_working[13]}) "
+ fi
+ if [[ $condition == '' ]];then
+ condition='N/A '
+ fi
+ condition="${C1}condition$SEP3${C2} $condition"
+ if [[ $B_EXTRA_DATA == 'true' ]];then
+ if [[ -n ${a_battery_working[15]} ]];then
+ model="${a_battery_working[15]} "
+ fi
+ if [[ -n ${a_battery_working[14]} ]];then
+ model="$model${a_battery_working[14]} "
+ fi
+ if [[ $model == '' ]];then
+ model='N/A '
+ fi
+ model="${C1}model$SEP3${C2} $model"
+
+ if [[ -n ${a_battery_working[1]} ]];then
+ status="${a_battery_working[1]} "
+ else
+ status="N/A "
+ fi
+ status="${C1}status$SEP3${C2} $status"
+ fi
+ if [[ $B_EXTRA_EXTRA_DATA == 'true' ]];then
+ if [[ -n ${a_battery_working[16]} ]];then
+ serial="${a_battery_working[16]} "
+ else
+ serial='N/A '
+ fi
+ serial="${C1}serial$SEP3${C2} $serial"
+ if [[ -n ${a_battery_working[6]} ]];then
+ voltage="${a_battery_working[6]}"
+ fi
+ if [[ -n ${a_battery_working[5]} ]];then
+ if [[ $voltage == '' ]];then
+ voltage='NA'
+ fi
+ voltage="$voltage/${a_battery_working[5]} "
+ fi
+ if [[ $voltage == '' ]];then
+ voltage='NA '
+ fi
+ voltage="${C1}volts$SEP3${C2} $voltage"
+ fi
+ if [[ $B_EXTRA_EXTRA_EXTRA_DATA == 'true' ]];then
+ if [[ -n ${a_battery_working[3]} ]];then
+ chemistry="${a_battery_working[3]} "
+ fi
+ if [[ -n ${a_battery_working[4]} ]];then
+ cycles="${C1}cycles$SEP3${C2} ${a_battery_working[4]} "
+ fi
+ # location is dmidecode only
+ if [[ -n ${a_battery_working[17]} ]];then
+ location="${C1}loc$SEP3${C2} ${a_battery_working[17]} "
+ fi
+ fi
+ if [[ -n ${a_battery_working[15]} ]];then
+ battery_string="${C1}${a_battery_working[0]}$SEP3${C2} $charge$condition"
+ battery_data="$model$chemistry$serial$status$cycles$location"
+ fi
+
+ if [[ ${A_BATTERY_DATA[0]} == 'dmidecode-error-'* ]];then
+ error_string=$( print_dmidecode_error 'bat' "${A_BATTERY_DATA[0]}" )
+ battery_string=${C2}$error_string
+ battery_data=''
+ voltage=''
+ fi
+
+ if [[ -n $battery_string ]];then
+ if [[ $( calculate_line_length "$battery_string$voltage$battery_data" ) -lt $COLS_INNER ]];then
+ #echo one
+ print_data=$( create_print_line "$line_starter" "$battery_string$voltage$battery_data" )
+ print_screen_output "$print_data"
+ # print the line
+ else
+ # keep the driver on the same line no matter what, looks weird alone on its own line
+ if [[ $( calculate_line_length "$battery_string$voltage$battery_data" ) -gt $COLS_INNER ]];then
+ if [[ $( calculate_line_length "$battery_string$voltage" ) -gt $COLS_INNER ]];then
+ print_data=$( create_print_line "$line_starter" "$battery_string" )
+ print_screen_output "$print_data"
+ line_starter=' '
+ battery_string=''
+ print_data=$( create_print_line "$line_starter" "$voltage" )
+ print_screen_output "$print_data"
+ voltage=''
+ else
+ print_data=$( create_print_line "$line_starter" "$battery_string$voltage" )
+ print_screen_output "$print_data"
+ line_starter=' '
+ voltage=''
+ battery_string=''
+ fi
+ #echo two
+ if [[ $battery_data != '' ]];then
+ print_data=$( create_print_line "$line_starter" "$battery_data" )
+ print_screen_output "$print_data"
+ fi
+ else
+ #echo three
+ print_data=$( create_print_line "$line_starter" "$battery_string$voltage$battery_data" )
+ print_screen_output "$print_data"
+ fi
+ fi
+ line_starter=' '
+ fi
+ done
+ elif [[ $B_SHOW_BATTERY_FORCED == 'true' ]];then
+ print_data=$( create_print_line "$line_starter" "No battery data found in /sys or dmidecode. Is one present?" )
+ print_screen_output "$print_data"
+ fi
+ eval $LOGFE
+}
+
print_cpu_data()
{
eval $LOGFS
@@ -11753,19 +12219,21 @@ print_cpu_flags_full()
eval $LOGFE
}
-# args: $1 - type [sys/default]; $2 - get_dmidecode_data error return
+# args: $1 - type [sys/bat/default]; $2 - get_dmidecode_data error return
print_dmidecode_error()
{
eval $LOGFS
local error_message='Unknown dmidecode error.'
local sysDmiError='Using '
- if [[ $1 == 'sys' ]];then
+ if [[ $1 == 'sys' || $1 == 'bat' ]];then
if [[ $B_FORCE_DMIDECODE == 'true' ]];then
sysDmiError='Forcing '
# dragonfly has /sys, but it's empty
- elif [[ $BSD_TYPE == '' || -d /sys/devices ]];then
+ elif [[ $1 == 'sys' ]] && [[ $BSD_TYPE == '' || -d /sys/devices ]];then
sysDmiError='No /sys/class/dmi; using '
+ #elif [[ $1 == 'bat' ]] && [[ $BSD_TYPE == '' || -d /sys/devices ]];then
+ # sysDmiError='No /sys/ battery; using '
else
sysDmiError='Using '
fi
@@ -11776,6 +12244,8 @@ print_dmidecode_error()
error_message="${sysDmiError}dmidecode: dmidecode is not installed."
elif [[ $2 == 'dmidecode-error-no-smbios-dmi-data' ]];then
error_message="${sysDmiError}dmidecode: no smbios data available. Old system?"
+ elif [[ $2 == 'dmidecode-error-no-battery-data' ]];then
+ error_message="${sysDmiError}dmidecode: no battery data available."
elif [[ $2 == 'dmidecode-error-unknown-error' ]];then
error_message="${sysDmiError}dmidecode: unknown error occured"
fi
diff --git a/inxi.1 b/inxi.1
index e517706..4b8fe73 100755
--- a/inxi.1
+++ b/inxi.1
@@ -1,10 +1,10 @@
-.TH INXI 1 "2015\-08\-20" inxi "inxi manual"
+.TH INXI 1 "2016\-04\-18" inxi "inxi manual"
.SH NAME
inxi \- Command line system information script for console and IRC
.SH SYNOPSIS
.B inxi \fR \- Single line, short form. Very basic output.
-.B inxi \fR[\fB\-AbCdDfFGhHiIlmMnNopPrRsSuw\fR] \fR[\fB\-c NUMBER\fR] \fR[\fB\-v NUMBER\fR]
+.B inxi \fR[\fB\-AbBCdDfFGhHiIlmMnNopPrRsSuw\fR] \fR[\fB\-c NUMBER\fR] \fR[\fB\-v NUMBER\fR]
.B inxi \fR[\fB\-t \fR(\fBc\fR or\fB m\fR or\fB cm\fR or\fB mc NUMBER\fR)] \fR[\fB\-x \-OPTION\fR(\fBs\fR)] \fR[\fB\-xx \-OPTION\fR(\fBs\fR)] \fR[\fB\-xxx \-OPTION\fR(\fBs\fR)]
@@ -31,19 +31,38 @@ Letters with numbers can have no gap or a gap at your discretion unless using \f
For example:
-.B inxi \-AG\fR or \fBinxi \-A \-G\fR or \fBinxi \-c10
+.B inxi \-AG\fR or \fBinxi \-A \-G\fR or \fBinxi \-c10\fR
.SH STANDARD OPTIONS
.TP
.B \-A
Show Audio/sound card information.
.TP
.B \-b
-Shows basic output, short form (previously \fB\-d\fR). Same as: \fBinxi \-v 2
+Shows basic output, short form (previously \fB\-d\fR). Same as: \fBinxi \-v 2\fR
+.TP
+.B \-B
+Shows Battery data, charge, condition, plus extra information (if battery present).
+Uses \fB/sys\fR or for BSDs, \fBdmidecode\fR. \fBdmidecode\fR does not have very much information,
+and none about current battery state/charge/voltage. Supports multiple batteries
+when using \fB/sys\fR data.
+
+Note on the \fBcharge\fR item, the output shows the current charge, and the percent of
+the available capacity, which can be less than the original design capacity. In the
+following example, the actual current capacity of the battery is \fB22.2 Wh\fR,
+so the charge shows what percent of the current capacity is charged.
+
+For example: \fB20.1 Wh 95.4%\fR
+
+The \fBcondition\fR item shows the current available capacity / original design capacity,
+then the percentage of original capacity available in the battery. In the following
+example, the battery capacity is only 61% of it's original amount.
+
+For example: \fB22.2/36.4 Wh 61%\fR
.TP
.B \-c \fR[\fB0\fR\-\fB32\fR]
Available color schemes. Scheme number is required.
-Supported color schemes: \fB0\-32
+Supported color schemes: \fB0\-42\fR
.TP
.B \-c \fR[\fB94\fR\-\fB99\fR]
Color selectors run a color selector option prior to inxi starting which lets
@@ -248,8 +267,8 @@ Supported levels: \fB0\-7\fR Examples :\fB inxi \-v 4 \fR or \fB inxi \-v4\fR
+ \fB\-G\fR + basic Disk + \fB\-I\fR.
.TP
.B \-v 2
-\- Adds networking card (\fB\-N\fR), Machine (\fB\-M\fR) data, and shows basic hard disk data
-(names only). Same as: \fBinxi \-b
+\- Adds networking card (\fB\-N\fR), Machine (\fB\-M\fR) data, Battery (\fB\-B\fR) (if available), and shows basic hard disk data
+(names only). Same as: \fBinxi \-b\fR
.TP
.B \-v 3
\- Adds advanced CPU (\fB\-C\fR); network (\fB\-n\fR) data; triggers \fB\-x\fR advanced data option.
@@ -307,6 +326,9 @@ The following shows which lines / items get extra information with each extra da
.TP
.B \-x \-A
\- Shows PCI Bus ID/Usb ID number of each Audio device.
+.TP
+.B \-x \-B
+\- Shows Vendor/Model, battery status (if battery present).
.TP
.B \-x \-C
\- bogomips on CPU (if available); CPU Flags (short list).
@@ -375,6 +397,11 @@ system Used/Total ram data if \fB\-t m\fR (memory) is not used AND \fB\-I\fR is
.B \-xx \-A
\- Adds vendor:product ID of each Audio device.
.TP
+.B \-xx \-B
+\- Adds serial number, voltage (if available).
+
+Note that \fBvolts\fR shows the data (if available) as: Voltage Now / Minimum Design Voltage
+.TP
.B \-xx \-C
\- Shows Minimum CPU speed (if available).
.TP
@@ -425,6 +452,11 @@ Supports most known display managers, like xdm, gdm, kdm, slim, lightdm, or mdm.
.B \-xx \-@ <11\-14>
\- Automatically uploads debugger data tar.gz file to \fIftp.techpatterns.com\fR.
.TP
+.B \-xxx \-B
+\- Adds battery chemistry (like: \fBLi-ion\fR), cycles (NOTE: there appears to be a problem with the Linux kernel
+obtaining the cycle count, so this almost always shows \fB0\fR. There's nothing that can be done about this glitch, the
+data is simply not availabe as of 2016-04-18), location (only available from dmidecode derived output).
+.TP
.B \-xxx \-m
\- Memory bus width: primary bus width, and if present, total width. eg: bus width: 64 bit (total: 72 bits). Note that total / data widths are mixed up sometimes in dmidecode output, so inxi will take the larger value as total if present. If no total width data is found, then inxi will not show that item.
.TP
diff --git a/inxi.1.gz b/inxi.1.gz
index 4c25d5c..7d8f3b2 100644
--- a/inxi.1.gz
+++ b/inxi.1.gz
Binary files differ
diff --git a/inxi.changelog b/inxi.changelog
index 1e5be2b..b8b6f57 100755
--- a/inxi.changelog
+++ b/inxi.changelog
@@ -1,4 +1,82 @@
=====================================================================================
+Version: 2.3.0
+Patch Version: 00
+Script Date: 2016-04-18
+-----------------------------------
+Changes:
+-----------------------------------
+New Feature, new version, new man page, new tarball. Laptop users should be happy,
+-B option now shows, if available, battery data. Quite good data for systems
+with /sys battery data, only rudimentary for systems using dmidecode (BSDs).
+dmidecode has no current voltage/charge/current supported capacity.
+
+Main row shows charge and condition. Condition shows you have much capacity the
+battery currently has vs its design capacity. Charge shows the Wh/percent of
+current capacity of battery (NOT the rated design capacity).
+
+-x adds battery vendor/model info, and battery status (like, charging, discharging,
+full).
+
+-xx adds battery serial number and voltage information. Note that voltage information
+is presented as Current Voltage / Designed minimum voltage.
+
+-xxx adds battery chemistry (like Li-ion), cycles (note: there's a bug somewhere in
+that makes the cycle count always be 0, I don't know if that's in the batteries,
+the linux kernel, but it's not inxi, just FYI, the data is simply 0 always in all
+my datasets so far.
+
+For dmidecode output, the location of the batter is also shown in -xxx
+
+-----------------------------------
+-- Harald Hope - Mon, 18 Apr 2016 16:55:12 -0700
+
+=====================================================================================
+Version: 2.2.38
+Patch Version: 00
+Script Date: 2016-03-31
+-----------------------------------
+Changes:
+-----------------------------------
+URGENT BUG FIX! This fixes a bug introduced in 2.2.36 2016-03-21. New version, new tarball.
+
+A sloppy unescaped / triggered a failure I didn't notice in partition info.
+
+Please update your inxi packages immediately if your version is 2016-03-21 or newer.
+
+-----------------------------------
+-- Harald Hope - Thu, 31 Mar 2016 15:08:54 -0700
+
+=====================================================================================
+Version: 2.2.37
+Patch Version: 00
+Script Date: 2016-03-30
+-----------------------------------
+Changes:
+-----------------------------------
+New version, new tarball. Tiny fix in distro detection, will now default in sequence
+on /etc/issue step to first test for os release and not mint, then lsb verison and
+not mint, then /etc/issue. This should keep the mint detection working well, as long
+as they keep mint string in the /etc/issue file, that is, but that's out of our control.
+
+-----------------------------------
+-- Harald Hope - Wed, 30 Mar 2016 13:28:40 -0700
+
+=====================================================================================
+Version: 2.2.36
+Patch Version: 00
+Script Date: 2016-03-21
+-----------------------------------
+Changes:
+-----------------------------------
+New version, new tarball. A tiny bug fix for kfreebsd, I know, right, nobody uses that.
+
+Also added in some more script color options however, which might be of use. These are
+aimed more at light terminal backgrounds.
+
+-----------------------------------
+-- Harald Hope - Mon, 21 Mar 2016 16:04:33 -0700
+
+=====================================================================================
Version: 2.2.35
Patch Version: 00
Script Date: 2016-02-29