diff --git a/inxi b/inxi index c4bb686..a35f70f 100755 --- a/inxi +++ b/inxi @@ -2,7 +2,7 @@ ######################################################################## SELF_NAME='inxi' # don't quote the following, parsers grab these too -SELF_VERSION=2.3.29 +SELF_VERSION=2.3.30 SELF_DATE=2017-07-29 SELF_PATCH=00 ######################################################################## @@ -516,6 +516,7 @@ DNSTOOL='' DOWNLOADER='wget' IRC_CLIENT='' IRC_CLIENT_VERSION='' +LINE_LENGTH=0 LSPCI_V_DATA='' LSPCI_N_DATA='' MEMORY='' @@ -1063,7 +1064,7 @@ set_display_width() # arg: $1 - version number: main/patch/date parse_version_data() { - # note, using ####[[:space:]]+ to avoid having this function also trip the version datas + # note, this is only now used for self updater function case $1 in date) SELF_DATE=$( gawk -F '=' ' @@ -1097,7 +1098,6 @@ initialize_paths() # this needs to be set here because various options call the parent initialize function directly. SELF_PATH=$( dirname "$0" ) - # Fallback paths put into $extra_paths; This might, among others, help on gentoo. # Now, create a difference of $PATH and $extra_paths and add that to $PATH: IFS=":" @@ -1120,6 +1120,7 @@ initialize_paths() # echo "PATH='$PATH'" ##/bin/sh -c 'echo "PATH in subshell=\"$PATH\""' } + # No args taken. check_recommended_apps() { @@ -12144,8 +12145,9 @@ calculate_line_length() # ansi:  irc: \x0312 # note: using special trick for bsd sed, tr - NOTE irc sed must use " double quote string=$( sed -e 's/'$ESC'\[[0-9]\{1,2\}\(;[0-9]\{1,2\}\)\{0,2\}m//g' -e "s/\\\x0[0-9]\{1,3\}//g" <<< $string ) - count=${#string} - echo $count + #echo $string + LINE_LENGTH=${#string} + # echo ${#string} } ## multiply the core count by the data to be calculated, bmips, cache @@ -12565,19 +12567,21 @@ print_audio_data() fi # only print alsa on last line if short enough, otherwise print on its own line if [[ $i -eq 0 ]];then - if [[ -n $alsa_data && $( calculate_line_length "$card_string$audio_data$alsa_data" ) -lt $COLS_INNER ]];then + calculate_line_length "$card_string$audio_data$alsa_data" + if [[ -n $alsa_data && $LINE_LENGTH -lt $COLS_INNER ]];then audio_data="$audio_data$alsa_data" alsa_data='' fi fi if [[ -n $audio_data ]];then - if [[ $( calculate_line_length "$card_string$audio_data" ) -lt $COLS_INNER ]];then + calculate_line_length "$card_string$audio_data" + if [[ $LINE_LENGTH -lt $COLS_INNER ]];then print_data=$( create_print_line "$line_starter" "$card_string$audio_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 "$card_string$audio_data" ) -gt $COLS_INNER ]];then + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then print_data=$( create_print_line "$line_starter" "$card_string" ) print_screen_output "$print_data" line_starter=' ' @@ -12593,7 +12597,8 @@ print_audio_data() done fi if [[ -n $alsa_data ]];then - if [[ $( calculate_line_length "${alsa_data/ALSA/Advanced Linux Sound Architecture}" ) -lt $COLS_INNER ]];then + calculate_line_length "${alsa_data/ALSA/Advanced Linux Sound Architecture}" + if [[ $LINE_LENGTH -lt $COLS_INNER ]];then # alsa_data=$( sed 's/ALSA/Advanced Linux Sound Architecture/' <<< $alsa_data ) alsa_data=${alsa_data/ALSA/Advanced Linux Sound Architecture} fi @@ -12741,15 +12746,17 @@ print_battery_data() fi if [[ -n $battery_string ]];then - if [[ $( calculate_line_length "$battery_string$voltage$battery_data" ) -lt $COLS_INNER ]];then + calculate_line_length "$battery_string$voltage$battery_data" + if [[ $LINE_LENGTH -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 + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then + calculate_line_length "$battery_string$voltage" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then print_data=$( create_print_line "$line_starter" "$battery_string" ) print_screen_output "$print_data" line_starter=' ' @@ -12964,7 +12971,8 @@ print_cpu_data() # echo icols: $COLS_INNER # echo tc: $TERM_COLUMNS # echo :${cpu_2_data}: - if [[ -n $cpu_2_data && $( calculate_line_length "$cpu_data $cpu_2_data" ) -gt $COLS_INNER ]];then + calculate_line_length "$cpu_data $cpu_2_data" + if [[ -n $cpu_2_data && $LINE_LENGTH -gt $COLS_INNER ]];then cpu_data=$( create_print_line "$line_starter" "$cpu_data" ) line_starter=' ' print_screen_output "$cpu_data" @@ -12998,8 +13006,8 @@ print_cpu_data() # echo $(calculate_line_length "$multi_cpu_starter$SEP3 $cpu_multi_clock_data" ) working_cpu="$max_speed${C1}$(( i + 1 ))$SEP3${C2} ${a_cpu_working[1]%.*} MHz " max_speed='' - if [[ -n $cpu_multi_clock_data && \ - $( calculate_line_length "$multi_cpu_starter$cpu_multi_clock_data$working_cpu" ) -gt $COLS_INNER ]];then + calculate_line_length "$multi_cpu_starter$cpu_multi_clock_data$working_cpu" + if [[ -n $cpu_multi_clock_data && $LINE_LENGTH -gt $COLS_INNER ]];then cpu_multi_clock_data=$( create_print_line " " "$multi_cpu_starter$cpu_multi_clock_data" ) print_screen_output "$cpu_multi_clock_data" multi_cpu_starter='' @@ -13283,7 +13291,8 @@ print_graphics_data() part_2_data="$card_bus_id$chip_id" if [[ ${#A_GRAPHICS_CARD_DATA[@]} -gt 1 ]];then - if [[ $( calculate_line_length "$part_1_data$part_2_data" ) -gt $COLS_INNER ]];then + calculate_line_length "$part_1_data$part_2_data" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then graphics_data=$( create_print_line "$line_starter" "$part_1_data" ) print_screen_output "$graphics_data" part_1_data='' @@ -13305,7 +13314,8 @@ print_graphics_data() fi # Print cards if not dual card system if [[ -n $part_1_data$part_2_data ]];then - if [[ $( calculate_line_length "$part_1_data$part_2_data" ) -gt $COLS_INNER ]];then + calculate_line_length "$part_1_data$part_2_data" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then graphics_data=$( create_print_line "$line_starter" "$part_1_data" ) print_screen_output "$graphics_data" part_1_data='' @@ -13327,8 +13337,9 @@ print_graphics_data() part_1_data="$display_server_string$driver_string" part_2_data="${C1}$res_tty$SEP3${C2} $screen_resolution $root_x_string" + calculate_line_length "$part_1_data $part_2_data" if [[ -n $( grep -vE '^[[:space:]]*$' <<< $part_1_data$part_2_data ) && \ - $( calculate_line_length "$part_1_data $part_2_data" ) -gt $COLS_INNER ]];then + $LINE_LENGTH -gt $COLS_INNER ]];then graphics_data=$( create_print_line "$line_starter" "$part_1_data" ) print_screen_output "$graphics_data" line_starter=' ' @@ -13374,7 +13385,8 @@ print_graphics_data() part_1_data="${C1}OpenGL$SEP3 renderer$SEP3${C2} $glx_renderer " part_2_data="${C1}version$SEP3${C2} $glx_version$direct_render_string" # echo $line_starter - if [[ $( calculate_line_length "$part_1_data$part_2_data" ) -gt $COLS_INNER ]];then + calculate_line_length "$part_1_data$part_2_data" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then graphics_data=$( create_print_line "$line_starter" "$part_1_data" ) print_screen_output "$graphics_data" part_1_data='' @@ -13476,7 +13488,8 @@ print_hard_disk_data() Line_Starter=' ' row_starter='' fi - if [[ $( calculate_line_length "$part_1_data$part_2_data" ) -gt $COLS_INNER ]];then + calculate_line_length "$part_1_data$part_2_data" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then hdd_data=$( create_print_line "$Line_Starter" "$part_1_data" ) print_screen_output "$hdd_data" part_1_data='' @@ -13499,7 +13512,8 @@ print_hard_disk_data() #echo 2 #fi else - if [[ $( calculate_line_length "$part_1_data$part_2_data" ) -gt $COLS_INNER ]];then + calculate_line_length "$part_1_data$part_2_data" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then hdd_data=$( create_print_line "$Line_Starter" "$part_1_data" ) print_screen_output "$hdd_data" part_1_data='' @@ -13513,8 +13527,8 @@ print_hard_disk_data() part_2_data='' fi fi - -# if [[ $( calculate_line_length "$part_2_data$part_1_data" ) -gt $COLS_INNER ]];then + # calculate_line_length "$part_2_data$part_1_data" +# if [[ $LINE_LENGTH -gt $COLS_INNER ]];then # if [[ -n $( grep -vE '^[[:space:]]*$' <<< $part_2_data ) ]];then # hdd_data=$( create_print_line "$Line_Starter" "$part_2_data" ) # print_screen_output "$hdd_data" @@ -13663,7 +13677,8 @@ print_info_data() # info_data="$info_data" closing_data="$client_data${C1}$SELF_NAME$SEP3${C2} $SELF_VERSION$SELF_PATCH" # sometimes gcc is very long, and default runlevel can be long with systemd, so create a gcc-less line first - if [[ $( calculate_line_length "$info_data$init_data$gcc_installed" ) -gt $COLS_INNER ]];then + calculate_line_length "$info_data$init_data$gcc_installed" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then # info_data=$info_data info_data=$( create_print_line "$line_starter" "$info_data" ) print_screen_output "$info_data" @@ -13672,7 +13687,8 @@ print_info_data() line_starter=' ' #echo 1 fi - if [[ $( calculate_line_length "$init_data$gcc_installed" ) -gt $COLS_INNER ]];then + calculate_line_length "$init_data$gcc_installed" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then info_data=$init_data info_data=$( create_print_line "$line_starter" "$info_data" ) print_screen_output "$info_data" @@ -13681,7 +13697,8 @@ print_info_data() line_starter=' ' #echo 2 fi - if [[ $( calculate_line_length "$info_data$init_data$gcc_installed$closing_data" ) -gt $COLS_INNER ]];then + calculate_line_length "$info_data$init_data$gcc_installed$closing_data" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then info_data=$info_data$init_data$gcc_installed info_data=$( create_print_line "$line_starter" "$info_data" ) print_screen_output "$info_data" @@ -13813,7 +13830,8 @@ print_machine_data() fi mobo_line="${C1}Mobo$SEP3${C2} $mobo_vendor ${C1}model$SEP3${C2} $mobo_model$mobo_version$mobo_serial" bios_line="${C1}$firmware_type$SEP3${C2} $bios_vendor ${C1}v$SEP3${C2} $bios_version ${C1}date$SEP3${C2} $bios_date$bios_rom" - if [[ $( calculate_line_length "$mobo_line$bios_line" ) -lt $COLS_INNER ]];then + calculate_line_length "$mobo_line$bios_line" + if [[ $LINE_LENGTH -lt $COLS_INNER ]];then mobo_line="$mobo_line $bios_line" bios_line='' fi @@ -13835,7 +13853,8 @@ print_machine_data() product_serial=" ${C1}serial$SEP3${C2} ${A_MACHINE_DATA[3]} " fi system_line="${C1}Device$SEP3${C2} $device ${C1}System$SEP3${C2} $system_vendor ${C1}product$SEP3${C2} $product_name$product_version$product_serial" - if [[ -n $chassis_line && $( calculate_line_length "$system_line$chassis_line" ) -lt $COLS_INNER ]];then + calculate_line_length "$system_line$chassis_line" + if [[ -n $chassis_line && $LINE_LENGTH -lt $COLS_INNER ]];then system_line="$system_line $chassis_line" chassis_line='' fi @@ -14000,13 +14019,15 @@ print_networking_data() card_string="${C1}Card$card_id$SEP3${C2} ${a_network_working[0]} " card_data="$driver_data$port_data" part_2_data="$pci_bus_id$chip_id" - if [[ $( calculate_line_length "$card_string$card_data$part_2_data" ) -gt $COLS_INNER ]];then + calculate_line_length "$card_string$card_data$part_2_data" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then network_data=$( create_print_line "$line_starter" "$card_string" ) line_starter=' ' card_string='' print_screen_output "$network_data" fi - if [[ $( calculate_line_length "$card_string$card_data$part_2_data" ) -gt $COLS_INNER ]];then + calculate_line_length "$card_string$card_data$part_2_data" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then network_data=$( create_print_line "$line_starter" "$card_string$card_data" ) print_screen_output "$network_data" line_starter=' ' @@ -14080,7 +14101,8 @@ print_network_advanced_data() fi network_data="${C1}IF$SEP3${C2} $if_id ${C1}state$SEP3${C2} $oper_state $speed_string$duplex_string" part_2_data="${C1}mac$SEP3${C2} $mac_id" - if [[ $( calculate_line_length "$network_data$part_2_data" ) -gt $COLS_INNER ]];then + calculate_line_length "$network_data$part_2_data" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then network_data=$( create_print_line " " "$network_data" ) print_screen_output "$network_data" network_data='' @@ -14303,20 +14325,23 @@ print_optical_drive_data() fi fi drive_data="${C1}$drive_type${counter}$SEP3${C2} $drive_string" - if [[ $( calculate_line_length "$drive_data$part_2_data" ) -lt $COLS_INNER ]];then + calculate_line_length "$drive_data$part_2_data" + if [[ $LINE_LENGTH -lt $COLS_INNER ]];then drive_data=$( create_print_line "$Line_Starter" "$drive_data$part_2_data" ) print_screen_output "$drive_data" Line_Starter=' ' drive_data='' part_2_data='' else - if [[ $( calculate_line_length "$drive_data" ) -gt $COLS_INNER ]];then + calculate_line_length "$drive_data" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then drive_data=$( create_print_line "$Line_Starter" "$drive_data" ) print_screen_output "$drive_data" Line_Starter=' ' drive_data='' fi - if [[ $( calculate_line_length "$drive_data$part_2_data" ) -lt $COLS_INNER ]];then + calculate_line_length "$drive_data$part_2_data" + if [[ $LINE_LENGTH -lt $COLS_INNER ]];then drive_data=$( create_print_line "$Line_Starter" "$drive_data$part_2_data" ) print_screen_output "$drive_data" Line_Starter=' ' @@ -14402,7 +14427,8 @@ print_optical_drive_data() fi drive_data="${C1}Features: speed$SEP3${C2} $speed $multisession" part_2_data="$audio${C1}dvd$SEP3${C2} $dvd ${C1}rw$SEP3${C2} $rw_support $state" - if [[ $( calculate_line_length "$drive_data$part_2_data" ) -lt $COLS_INNER ]];then + calculate_line_length "$drive_data$part_2_data" + if [[ $LINE_LENGTH -lt $COLS_INNER ]];then drive_data=$( create_print_line "$Line_Starter" "$drive_data$part_2_data" ) print_screen_output "$drive_data" Line_Starter=' ' @@ -14497,13 +14523,14 @@ print_partition_data() id_size_fs="${C1}ID-$((part_id+1))$SEP3${C2} $partitionIdClean ${C1}size$SEP3${C2} ${a_partition_working[1]} $partition_used$full_fs$full_dev" label_uuid="$full_label$full_uuid" # label/uuid always print one per line, so only wrap if it's very long + calculate_line_length "${a_partition_data[$counter]}$id_size_fs$label_uuid" if [[ $B_SHOW_UUIDS == 'true' || $B_SHOW_LABELS == 'true' ]] && \ - [[ $( calculate_line_length "${a_partition_data[$counter]}$id_size_fs$label_uuid" ) -gt $COLS_INNER ]];then + [[ $LINE_LENGTH -gt $COLS_INNER ]];then a_partition_data[$counter]="$id_size_fs" ((counter++)) a_partition_data[$counter]="$label_uuid" else - if [[ $( calculate_line_length "${a_partition_data[$counter]}$id_size_fs$label_uuid" ) -gt $COLS_INNER ]];then + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then a_partition_data[$counter]="${a_partition_data[$counter]}" ((counter++)) a_partition_data[$counter]="$id_size_fs$label_uuid" @@ -15028,7 +15055,8 @@ print_ram_data() fi memory_line="${C1}Array-$array_counter capacity$SEP3${C2} $max_capacity ${C1}devices$SEP3${C2} $nu_of_devices ${C1}EC$SEP3${C2} $error_correction " line_2="$max_module_size$module_voltage" - if [[ -n $line_2 && $( calculate_line_length "$memory_line$line_2" ) -gt $COLS_INNER ]];then + calculate_line_length "$memory_line$line_2" + if [[ -n $line_2 && $LINE_LENGTH -gt $COLS_INNER ]];then memory_line=$( create_print_line "$line_starter" "$memory_line" ) print_screen_output "$memory_line" memory_line="$line_2" @@ -15151,7 +15179,8 @@ print_ram_data() fi fi memory_line="${C1}Device-$device_counter$SEP3${C2} $locator ${C1}size$SEP3${C2} $device_size$bank_connection $device_speed" - if [[ $( calculate_line_length "$memory_line$device_type" ) -le $COLS_INNER ]];then + calculate_line_length "$memory_line$device_type" + if [[ $LINE_LENGTH -le $COLS_INNER ]];then memory_line="$memory_line$device_type" device_type='' fi @@ -15159,12 +15188,14 @@ print_ram_data() line_2="$device_type$bus_width" # echo $( calculate_line_length "$memory_line" ) # echo $( calculate_line_length "$memory_line$line_2" ) - if [[ $( calculate_line_length "$memory_line$line_2$line_3" ) -gt $COLS_INNER ]];then + calculate_line_length "$memory_line$line_2$line_3" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then memory_line=$( create_print_line "$line_starter" "$memory_line" ) print_screen_output "$memory_line" memory_line="$line_2" line_starter=' ' - if [[ -n $memory_line && -n $line_3 && $( calculate_line_length "$memory_line$line_3" ) -gt $COLS_INNER ]];then + calculate_line_length "$memory_line$line_3" + if [[ -n $memory_line && -n $line_3 && $LINE_LENGTH -gt $COLS_INNER ]];then memory_line=$( create_print_line "$line_starter" "$memory_line" ) print_screen_output "$memory_line" memory_line="$line_3" @@ -15489,14 +15520,15 @@ print_system_data() host_kernel_string="$host_string${C1}Kernel$SEP3${C2} $CURRENT_KERNEL$bits " de_string="${C1}$desktop_type$SEP3${C2} $desktop_environment$de_extra_data$dm_data " distro_string="${C1}$distro_os$SEP3${C2} $distro " - - if [[ $( calculate_line_length "$host_kernel_string$de_string" ) -gt $COLS_INNER ]];then + calculate_line_length "$host_kernel_string$de_string" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then system_data=$( create_print_line "$line_starter" "$host_kernel_string" ) print_screen_output "$system_data" host_kernel_string='' line_starter=' ' fi - if [[ $( calculate_line_length "$host_kernel_string$de_string$distro_string" ) -gt $COLS_INNER ]];then + calculate_line_length "$host_kernel_string$de_string$distro_string" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then system_data=$( create_print_line "$line_starter" "$host_kernel_string$de_string" ) print_screen_output "$system_data" host_kernel_string='' @@ -15569,7 +15601,8 @@ print_unmounted_partition_data() full_string="$full_dev$full_size" part_2_data="$full_fs$full_label$full_uuid" fi - if [[ $( calculate_line_length "$full_string$part_2_data" ) -gt $COLS_INNER ]];then + calculate_line_length "$full_string$part_2_data" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then unmounted_data=$( create_print_line "$line_starter" "$full_string" ) print_screen_output "$unmounted_data" line_starter=' ' diff --git a/inxi.changelog b/inxi.changelog index 28475b7..4ab1315 100644 --- a/inxi.changelog +++ b/inxi.changelog @@ -1,3 +1,16 @@ +===================================================================================== +Version: 2.3.30 +Patch Version: 00 +Script Date: 2017-07-29 +----------------------------------- +Changes: +----------------------------------- +New version, tarball. More optimizations, I'm not sure these will make a big difference +but I believe the overall collection has dropped execution time by around 10% or so. + +----------------------------------- +-- Harald Hope - Sat, 29 Jul 2017 19:36:55 -0700 + ===================================================================================== Version: 2.3.29