diff --git a/inxi b/inxi index 5a6da78..8d4a189 100755 --- a/inxi +++ b/inxi @@ -1,9 +1,9 @@ #!/usr/bin/env bash ######################################################################## #### Script Name: inxi -#### Version: 2.0.0 -#### Date: 2014-03-12 -#### Patch Number: 03-b1 +#### Version: 2.1.8 +#### Date: 2014-03-24 +#### Patch Number: 01-b1 ######################################################################## #### SPECIAL THANKS ######################################################################## @@ -54,7 +54,7 @@ #### * bash >=3.0 (bash); df, readlink, stty, tr, uname, wc (coreutils); #### gawk (gawk); grep (grep); lspci (pciutils); #### ps, uptime (procps); find (findutils) -#### * Also the proc filesystem should be present and mounted +#### * Also the proc filesystem should be present and mounted for Linux #### * Some features, like -M and -d will not work, or will work incompletely, #### if /sys is missing #### @@ -114,6 +114,10 @@ #### * To 'return' a value in a function, use 'echo '. #### * For gawk: use always if ( num_of_cores > 1 ) { hanging { starter for all blocks #### This lets us use one method for all gawk structures, including BEGIN/END, if, for, etc +#### * Using ${VAR} is about 30% slower than $VAR because bash has to check the stuff for actions +#### SUBSHELLS ARE EXPENSIVE! - run these two if you do not believe me. +#### time for (( i=0; i<1000; i++ )) do ff='/usr/local/bin/foo.pid';ff=${ff##*/};ff=${ff%.*};done;echo $ff +#### time for (( i=0; i<1000; i++ )) do ff='/usr/local/bin/foo.pid';ff=$( basename $ff | cut -d '.' -f 1 );done;echo $ff #### #### VARIABLE/FUNCTION NAMING: #### * All functions should follow standard naming--verb adjective noun. @@ -139,7 +143,7 @@ #### ln -s /usr/share/apps/konversation/scripts/inxi #### DCOP doesn't like \n, so avoid using it for most output unless required, as in error messages. #### * print_screen_output " " # requires space, not null, to avoid error in for example in irssi -#### * For logging of array data, array must be placed into the temp_array, otherwise only the first key logs +#### * For logging of array data, array must be placed into the a_temp, otherwise only the first key logs #### * In gawk search patterns, . is a wildcard EXCEPT in [0-9.] type containers, then it's a literal #### So outside of bracketed items, it must be escaped, \. but inside, no need. Outside of gawk it should #### be escaped in search patterns if you are using it as a literal. @@ -193,37 +197,50 @@ ## NOTE: we can use hwinfo if it's available in all systems, or most, to get ## a lot more data and verbosity levels going -# set to default LANG to avoid locales errors with , or . -LANG=C -### Variable initializations: null values -BSD_TYPE='' -BSD_VERSION= -CMDL_MAX='' -COLOR_SCHEME='' + +### DISTRO MAINTAINER FLAGS ### +# flag to allow distro maintainers to turn off update features. If false, turns off +# -U and -! testing/advanced update options, as well as removing the -U help menu item +# NOTE: Usually you want to create these in /etc/inxi.conf to avoid having to update each time +B_ALLOW_UPDATE='true' +B_ALLOW_WEATHER='true' + +### USER CONFIGS: SET IN inxi.conf file see wiki for directions ### +# http://code.google.com/p/inxi/wiki/script_configuration_files # override in user config if desired, seems like less than .3 doesn't work as reliably CPU_SLEEP='0.3' -DEV_DISK_ID='' -DEV_DISK_LABEL='' -DEV_DISK_MAPPER='' -DEV_DISK_UUID='' -DMIDECODE_DATA='' FILTER_STRING='' -IRC_CLIENT='' -IRC_CLIENT_VERSION='' -LINE_MAX='' -# for features like help/version will fit to terminal / console screen width -LINE_MAX_BASIC='120' -LINE_MAX_CONSOLE='115' -LINE_MAX_IRC='105' + +# for features like help/version will fit to terminal / console screen width. Console +# widths will be dynamically set in main() based on cols in term/console +COLS_MAX_CONSOLE='115' +COLS_MAX_IRC='105' +# note, this is console out of x/display server, will also be set dynamically +# not used currently, but maybe in future +COLS_MAX_NO_DISPLAY='140' PS_COUNT=5 -PS_THROTTLED='' -REPO_DATA='' -SED_I='-i' # for gnu sed, will be set to -i '' for bsd sed -SED_RX='-r' # for gnu sed, will be set to -E for bsd sed for backward compatibility # change to less, or more if you have very slow connection WGET_TIMEOUT=8 +### END USER CONFIGS ### -### primary data array holders ## usage: 'A_' +### LOCALIZATION - DO NOT CHANGE! ### +# set to default LANG to avoid locales errors with , or . +LANG=C +# Make sure every program speaks English. +LC_ALL="C" +export LC_ALL + +### ARRAYS ### +## Prep +# 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 +# therefore results in nothing. +shopt -u nullglob +## info on bash built in: $IFS - http://tldp.org/LDP/abs/html/internalvariables.html +# Backup the current Internal Field Separator +ORIGINAL_IFS="$IFS" + +## Initialize A_ALSA_DATA='' A_AUDIO_DATA='' A_CMDL='' @@ -250,12 +267,7 @@ A_UNMOUNTED_PARTITION_DATA='' A_WEATHER_DATA='' A_DISPLAY_SERVER_DATA='' -### Boolean true/false globals ## usage: 'B_' -## Distro maintainer flags ## -# flag to allow distro maintainers to turn off update features. If false, turns off -# -U and -! testing/advanced update options, as well as removing the -U help menu item -B_ALLOW_UPDATE='true' -B_ALLOW_WEATHER='true' +### BOOLEANS ### ## standard boolean flags ## B_BSD_RAID='false' B_COLOR_SCHEME_SET='false' @@ -292,10 +304,10 @@ B_RAID_SET='false' B_ROOT='false' B_RUN_COLOR_SELECTOR='false' B_RUNNING_IN_DISPLAY='false' # in x type display server -# Running in a shell? Defaults to false, and is determined later. -B_RUNNING_IN_SHELL='false' if tty >/dev/null;then - B_RUNNING_IN_SHELL='true' + B_IRC='false' +else + B_IRC='true' fi # this sets the debug buffer B_SCRIPT_UP='false' @@ -348,7 +360,7 @@ B_USE_LOGGING='false' B_UUID_SET='false' B_XORG_LOG='false' -### Directory/file exist flags; test as [[ $(boolean) ]] not [[ $boolean ]] +## Directory/file exist flags; test as [[ $(boolean) ]] not [[ $boolean ]] B_ASOUND_DEVICE_FILE='false' B_ASOUND_VERSION_FILE='false' B_BASH_ARRAY='false' @@ -364,64 +376,21 @@ B_PARTITIONS_FILE='false' # B_PROC_DIR='false' B_SCSI_FILE='false' -### File's used when present -FILE_ASOUND_DEVICE='/proc/asound/cards' -FILE_ASOUND_MODULES='/proc/asound/modules' # not used but maybe for -A? -FILE_ASOUND_VERSION='/proc/asound/version' -FILE_CPUINFO='/proc/cpuinfo' -FILE_DMESG_BOOT='/var/run/dmesg.boot' -FILE_LSB_RELEASE='/etc/lsb-release' -FILE_MDSTAT='/proc/mdstat' -FILE_MEMINFO='/proc/meminfo' -FILE_MODULES='/proc/modules' -FILE_MOUNTS='/proc/mounts' -FILE_OS_RELEASE='/etc/os-release' -FILE_PARTITIONS='/proc/partitions' -FILE_SCSI='/proc/scsi/scsi' -FILE_XORG_LOG='/var/log/Xorg.0.log' # if not found, search and replace with actual location - ## app tested for and present, to avoid repeat tests B_FILE_TESTED='false' B_HDDTEMP_TESTED='false' B_MODINFO_TESTED='false' B_SUDO_TESTED='false' -FILE_PATH='' -HDDTEMP_PATH='' -MODINFO_PATH='' -SUDO_PATH='' -### Variable initializations: constants +### CONSTANTS/INITIALIZE - SOME MAY BE RESET LATER ### DCOPOBJ="default" DEBUG=0 # Set debug levels from 1-10 (8-10 trigger logging levels) # Debug Buffer Index, index into a debug buffer storing debug messages until inxi is 'all up' DEBUG_BUFFER_INDEX=0 ## note: the debugger rerouting to /dev/null has been moved to the end of the get_parameters function ## so -@[number] debug levels can be set if there is a failure, otherwise you can't even see the errors - -# Defaults to 2, make this 1 for normal, 0 for no colorcodes at all. Use following variables in config -# files to change defaults for each type, or global -# Same as runtime parameter. -DEFAULT_COLOR_SCHEME=2 -# Always leave these blank, these are only going to be set in inxi.conf files, that makes testing -# for user changes easier after sourcing the files -GLOBAL_COLOR_SCHEME='' -IRC_COLOR_SCHEME='' -IRC_CONS_COLOR_SCHEME='' -IRC_X_TERM_COLOR_SCHEME='' -CONSOLE_COLOR_SCHEME='' -VIRT_TERM_COLOR_SCHEME='' - -# Default indentation level -INDENT=10 - -# logging eval variables, start and end function: Insert to LOGFS LOGFE when debug level >= 8 -LOGFS_STRING='log_function_data fs $FUNCNAME "$( echo $@ )"' -LOGFE_STRING='log_function_data fe $FUNCNAME' -LOGFS='' -LOGFE='' -# uncomment for debugging from script start -# LOGFS=$LOGFS_STRING -# LOGFE=$LOGFE_STRING +SED_I='-i' # for gnu sed, will be set to -i '' for bsd sed +SED_RX='-r' # for gnu sed, will be set to -E for bsd sed for backward compatibility # default to false, no konversation found, 1 is native konvi (qt3/KDE3) script mode, 2 is /cmd inxi start, ## 3 is Konversation > 1.2 (qt4/KDE4) @@ -440,24 +409,38 @@ VERBOSITY_LEVEL=0 # Supported number of verbosity levels, including 0 VERBOSITY_LEVELS=7 -# 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 -# therefore results in nothing. -shopt -u nullglob -## info on bash built in: $IFS - http://tldp.org/LDP/abs/html/internalvariables.html -# Backup the current Internal Field Separator -ORIGINAL_IFS="$IFS" +### LOGGING ### +## logging eval variables, start and end function: Insert to LOGFS LOGFE when debug level >= 8 +LOGFS_STRING='log_function_data fs $FUNCNAME "$( echo $@ )"' +LOGFE_STRING='log_function_data fe $FUNCNAME' +LOGFS='' +LOGFE='' +# uncomment for debugging from script start +# LOGFS=$LOGFS_STRING +# LOGFE=$LOGFE_STRING -# These two determine separators in single line output, to force irc clients not to break off sections -SEP1='~' -SEP2=' ' -# these will assign a separator to non irc states. Important! Using ':' can trigger stupid emoticon -# behaviors in output on IRC, so do not use those. -SEP3_IRC='' -SEP3_CONSOLE=':' -SEP3='' # do not set, will be set dynamically +### FILE NAMES/PATHS/URLS - must be non root writable ### +# File's used when present +FILE_ASOUND_DEVICE='/proc/asound/cards' +FILE_ASOUND_MODULES='/proc/asound/modules' # not used but maybe for -A? +FILE_ASOUND_VERSION='/proc/asound/version' +FILE_CPUINFO='/proc/cpuinfo' +FILE_DMESG_BOOT='/var/run/dmesg.boot' +FILE_LSB_RELEASE='/etc/lsb-release' +FILE_MDSTAT='/proc/mdstat' +FILE_MEMINFO='/proc/meminfo' +FILE_MODULES='/proc/modules' +FILE_MOUNTS='/proc/mounts' +FILE_OS_RELEASE='/etc/os-release' +FILE_PARTITIONS='/proc/partitions' +FILE_SCSI='/proc/scsi/scsi' +FILE_XORG_LOG='/var/log/Xorg.0.log' # if not found, search and replace with actual location + +FILE_PATH='' +HDDTEMP_PATH='' +MODINFO_PATH='' +SUDO_PATH='' -### Script names/paths - must be non root writable SCRIPT_DATA_DIR="$HOME/.inxi" ALTERNATE_FTP='' # for data uploads ALTERNATE_WEATHER_LOCATION='' # weather alternate location @@ -483,25 +466,68 @@ SCRIPT_DOWNLOAD_DEV='http://smxi.org/test/' WAN_IP_URL='http://smxi.org/opt/ip.php' KONVI_CFG="konversation/scripts/$SCRIPT_NAME.conf" # relative path to $(kde-config --path data) -LINES=100 -COLUMNS=80 -# http://stackoverflow.com/questions/1780483/lines-and-columns-environmental-variables-lost-in-a-script -if [[ -n $( type -p tput ) ]];then - LINES=$(tput lines) - COLUMNS=$(tput cols) -fi -# double check, just in case it's missing functionality or whatever -if [[ -z ${COLUMNS##[0-9]*} ]];then - LINES=100 - COLUMNS=80 -fi +### INITIALIZE VARIABLES NULL ### +BSD_TYPE='' +BSD_VERSION= +CMDL_MAX='' -### Script Localization -# Make sure every program speaks English. -LC_ALL="C" -export LC_ALL +DEV_DISK_ID='' +DEV_DISK_LABEL='' +DEV_DISK_MAPPER='' +DEV_DISK_UUID='' +DMIDECODE_DATA='' +IRC_CLIENT='' +IRC_CLIENT_VERSION='' +PS_THROTTLED='' +REPO_DATA='' -### Output Colors +### LAYOUT ### +# These two determine separators in single line output, to force irc clients not to break off sections +SEP1='~' +SEP2=' ' +# these will assign a separator to non irc states. Important! Using ':' can trigger stupid emoticon +# behaviors in output on IRC, so do not use those. +SEP3_IRC='' +SEP3_CONSOLE=':' +SEP3='' # do not set, will be set dynamically +LINE1='---------------------------------------------------------------------------' +LINE2='- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -' + +# Default indentation level. NOTE: actual indent is 1 greater to allow for spacing +INDENT=10 + +### COLUMN WIDTHS ### +COLS_INNER='' ## for width minus INDENT +COLS_MAX='' + +# these will be set dynamically in main() +TERM_COLUMNS=80 +TERM_LINES=100 + +# Only for legacy user config files se we can test and convert the var name +LINE_MAX_CONSOLE='' +LINE_MAX_IRC='' + +### COLORS ### +# Defaults to 2, make this 1 for normal, 0 for no colorcodes at all. Use following variables in config +# files to change defaults for each type, or global +# Same as runtime parameter. +DEFAULT_COLOR_SCHEME=2 +## color variables - set dynamically +COLOR_SCHEME='' +C1='' +C2='' +CN='' +## Always leave these blank, these are only going to be set in inxi.conf files, that makes testing +## for user changes easier after sourcing the files +GLOBAL_COLOR_SCHEME='' +IRC_COLOR_SCHEME='' +IRC_CONS_COLOR_SCHEME='' +IRC_X_TERM_COLOR_SCHEME='' +CONSOLE_COLOR_SCHEME='' +VIRT_TERM_COLOR_SCHEME='' + +## Output colors # A more elegant way to have a scheme that doesn't print color codes (neither ANSI nor mIRC) at all. See below. unset EMPTY # DGREY BLACK RED DRED GREEN DGREEN YELLOW DYELLOW @@ -558,12 +584,12 @@ RED,WHITE,NORMAL BLUE,WHITE,NORMAL ) -## Actual color variables -C1='' -C2='' -CN='' +# 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 +# from Konversation! -### Distro Data +## DISTRO DATA/ID ## # In cases of derived distros where the version file of the base distro can also be found under /etc, # the derived distro's version file should go first. (Such as with Sabayon / Gentoo) DISTROS_DERIVED="antix-version aptosid-version kanotix-version knoppix-version mandrake-release pardus-release sabayon-release siduction-version sidux-version solusos-release turbolinux-release zenwalk-version" @@ -578,10 +604,10 @@ DISTROS_OS_RELEASE_GOOD="arch-release SuSE-release" # DSL (Bash 2.05b: grep -m doesn't work; arrays won't work) --> unusable output # Puppy Linux 4.1.2 (Bash 3.0: arrays won't work) --> works partially -### Bans Data +## OUTPUT FILTERS/SEARCH ## # Note that \ bans only words, not parts of strings; in \ you can't use punctuation characters like . or , # we're saving about 10+% of the total script exec time by hand building the ban lists here, using hard quotes. -BAN_LIST_NORMAL='chipset|components|computing|computer|corporation|communications|electronics|electrical|electric|gmbh|group|industrial|international|revision|semiconductor|software|technologies|technology|ltd\.|\|inc\.|\|intl\.|co\.|\|corp\.|\|\(tm\)|\(r\)|®|\(rev ..\)' +BAN_LIST_NORMAL='chipset|components|computing|computer|corporation|communications|electronics|electrical|electric|gmbh|group|incorporation|industrial|international|nee|revision|semiconductor|software|technologies|technology|ltd\.|\|inc\.|\|intl\.|co\.|\|corp\.|\|\(tm\)|\(r\)|®|\(rev ..\)' BAN_LIST_CPU='@|cpu deca|dual core|dual-core|tri core|tri-core|quad core|quad-core|ennea|genuine|hepta|hexa|multi|octa|penta|processor|single|triple|[0-9\.]+ *[MmGg][Hh][Zz]' SENSORS_GPU_SEARCH='intel|radeon|nouveau' @@ -595,11 +621,6 @@ USB_NETWORK_SEARCH="$USB_NETWORK_SEARCH|Actiontec.*Wireless|Actiontec.*Network|A # belkin=050d; d-link=07d1; netgear=0846; ralink=148f; realtek=0bda; USB_NETWORK_SEARCH="$USB_NETWORK_SEARCH|050d:935b|0bda:8189|0bda:8197" -# 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 -# from Konversation! - ######################################################################## #### MAIN: Where it all begins ######################################################################## @@ -623,7 +644,48 @@ main() if [[ -s $HOME/.$SCRIPT_NAME/$SCRIPT_NAME.conf ]];then source $HOME/.$SCRIPT_NAME/$SCRIPT_NAME.conf fi - + ## sometimes tput will trigger an error (mageia) if irc client + if [[ $B_IRC == 'false' ]];then + if type -p tput &>/dev/null;then + TERM_COLUMNS=$(tput cols) + TERM_LINES=$(tput lines) + fi + # double check, just in case it's missing functionality or whatever + if [[ -n ${TERM_COLUMNS##[0-9]*} ]];then + TERM_COLUMNS=80 + TERM_LINES=100 + fi + fi + # Convert to new variable names if set in config files, legacy test + if [[ -n $LINE_MAX_CONSOLE ]];then + COLS_MAX_CONSOLE=$LINE_MAX_CONSOLE + fi + if [[ -n $LINE_MAX_IRC ]];then + COLS_MAX_IRC=$LINE_MAX_IRC + fi + # this lets you set different widths for in or out of display server +# if [[ $B_RUNNING_IN_DISPLAY == 'false' && -n $COLS_MAX_NO_DISPLAY ]];then +# COLS_MAX_CONSOLE=$COLS_MAX_NO_DISPLAY +# fi + # TERM_COLUMNS is set in top globals, using tput cols + # echo tc: $TERM_COLUMNS cmc: $COLS_MAX_CONSOLE + if [[ $TERM_COLUMNS -lt $COLS_MAX_CONSOLE ]];then + COLS_MAX_CONSOLE=$TERM_COLUMNS + fi + # adjust, some terminals will wrap if output cols == term cols + COLS_MAX_CONSOLE=$(( $COLS_MAX_CONSOLE - 2 )) + # echo cmc: $COLS_MAX_CONSOLE + # comes after source for user set stuff + if [[ $B_IRC == 'false' ]];then + COLS_MAX=$COLS_MAX_CONSOLE + else + COLS_MAX=$COLS_MAX_IRC + fi +# echo SCHEME $SCHEME +# echo B_IRC $B_IRC +# echo sep3: $SEP3 + COLS_INNER=$(( $COLS_MAX - $INDENT - 1 )) + # echo cm: $COLS_MAX ci: $COLS_INNER # Check for dependencies BEFORE running ANYTHING else except above functions # Not all distro's have these depends installed by default. Don't want to run # this if the user is requesting to see this information in the first place @@ -664,8 +726,8 @@ main() IFS=":" for kde_config in $( kde-config --path data ) do - if [[ -r ${kde_config}${KONVI_CFG} ]];then - source "${kde_config}${KONVI_CFG}" + if [[ -r $kde_config$KONVI_CFG ]];then + source "$kde_config$KONVI_CFG" break fi done @@ -697,7 +759,7 @@ main() if [[ -n $GLOBAL_COLOR_SCHEME ]];then color_scheme=$GLOBAL_COLOR_SCHEME else - if [[ $B_RUNNING_IN_SHELL == 'true' ]];then + if [[ $B_IRC == 'false' ]];then if [[ -n $CONSOLE_COLOR_SCHEME && -z $DISPLAY ]];then color_scheme=$CONSOLE_COLOR_SCHEME elif [[ -n $VIRT_TERM_COLOR_SCHEME ]];then @@ -716,8 +778,7 @@ main() set_color_scheme $color_scheme fi fi - if [[ $B_RUNNING_IN_SHELL == 'true' ]];then - LINE_MAX=$LINE_MAX_CONSOLE + if [[ $B_IRC == 'false' ]];then SEP3=$SEP3_CONSOLE else # too hard to read if no colors, so force that for users on irc @@ -726,9 +787,8 @@ main() else SEP3=$SEP3_IRC fi - LINE_MAX=$LINE_MAX_IRC fi - + # all the pre-start stuff is in place now B_SCRIPT_UP='true' script_debugger "Debugger: $SCRIPT_NAME is up and running..." @@ -737,7 +797,7 @@ main() print_it_out ## last steps - if [[ $B_RUNNING_IN_SHELL == 'true' && $SCHEME -gt 0 ]];then + if [[ $B_IRC == 'false' && $SCHEME -gt 0 ]];then echo -n "" fi eval $LOGFE @@ -759,7 +819,7 @@ initialize_data() { eval $LOGFS BSD_VERSION=$( uname -s 2>/dev/null | tr '[A-Z]' '[a-z]' ) - + # note: archbsd says they are a freebsd distro, so assuming it's the same as freebsd if [[ -n $( grep 'bsd' <<< "$BSD_VERSION" ) ]];then # GNU/kfreebsd will by definition have GNU tools like sed/grep @@ -794,53 +854,40 @@ initialize_data() B_PORTABLE='true' fi fi - - if [[ -e $FILE_CPUINFO ]]; then B_CPUINFO_FILE='true' fi - if [[ -e $FILE_MEMINFO ]];then B_MEMINFO_FILE='true' fi - if [[ -e $FILE_ASOUND_DEVICE ]];then B_ASOUND_DEVICE_FILE='true' fi - if [[ -e $FILE_ASOUND_VERSION ]];then B_ASOUND_VERSION_FILE='true' fi - if [[ -f $FILE_LSB_RELEASE ]];then B_LSB_FILE='true' fi - if [[ -f $FILE_OS_RELEASE ]];then B_OS_RELEASE_FILE='true' fi - if [[ -e $FILE_SCSI ]];then B_SCSI_FILE='true' fi - if [[ -n $DISPLAY ]];then B_SHOW_DISPLAY_DATA='true' B_RUNNING_IN_DISPLAY='true' fi - if [[ -e $FILE_MDSTAT ]];then B_MDSTAT_FILE='true' fi - if [[ -e $FILE_MODULES ]];then B_MODULES_FILE='true' fi - if [[ -e $FILE_MOUNTS ]];then B_MOUNTS_FILE='true' fi - if [[ -e $FILE_PARTITIONS ]];then B_PARTITIONS_FILE='true' fi @@ -849,7 +896,7 @@ initialize_data() B_XORG_LOG='true' else # Detect location of the Xorg log file - if [[ -n $( type -p xset ) ]]; then + if type -p xset &>/dev/null; then FILE_XORG_LOG=$( xset q 2>/dev/null | grep -i 'Log file' | gawk '{print $3}') if [[ -e $FILE_XORG_LOG ]];then B_XORG_LOG='true' @@ -919,11 +966,10 @@ initialize_paths() done IFS="$ORIGINAL_IFS" - PATH="${PATH}${added_path}" - ##echo "PATH='$PATH'" + PATH="$PATH$added_path" + # echo "PATH='$PATH'" ##/bin/sh -c 'echo "PATH in subshell=\"$PATH\""' } - # No args taken. check_recommended_apps() { @@ -942,22 +988,22 @@ check_recommended_apps() script_debugger "Suggestion: update to Bash v3.1 for optimal inxi output" fi # test for a few apps that bsds may not have after initial tests - if [[ -n $( type -p lspci ) ]];then + if type -p lspci &>/dev/null;then B_LSPCI='true' fi if [[ -n $BSD_TYPE ]];then - if [[ -n $( type -p sysctl ) ]];then + if type -p sysctl &>/dev/null;then B_SYSCTL='true' fi - if [[ -n $( type -p pciconf ) ]];then + if type -p pciconf &>/dev/null;then B_PCICONF='true' fi fi # now setting qdbus/dcop for first run, some systems can have both by the way - if [[ -n $( type -p qdbus ) ]];then + if type -p qdbus &>/dev/null;then B_QDBUS='true' fi - if [[ -n $( type -p dcop ) ]];then + if type -p dcop &>/dev/null;then B_DCOP='true' fi eval $LOGFE @@ -968,7 +1014,7 @@ check_recommended_apps() check_required_apps() { eval $LOGFS - local app_name='' app_path='' + local app_name='' # bc removed from deps for now local depends="df gawk grep ps readlink tr uname uptime wc" @@ -987,8 +1033,7 @@ check_required_apps() if [[ $B_RUNNING_IN_DISPLAY == 'true' ]];then for app_name in $x_apps do - app_path=$( type -p $app_name ) - if [[ -z $app_path ]];then + if ! type -p $app_name &>/dev/null;then script_debugger "Resuming in non X mode: $app_name not found. For package install advice run: $SCRIPT_NAME --recommends" B_SHOW_DISPLAY_DATA='false' break @@ -1000,8 +1045,7 @@ check_required_apps() for app_name in $depends do - app_path=$( type -p $app_name ) - if [[ -z $app_path ]];then + if ! type -p $app_name &>/dev/null;then error_handler 5 "$app_name" fi done @@ -1044,7 +1088,7 @@ set_color_scheme() fi # Set a global variable to allow checking for chosen scheme later SCHEME="$1" - if [[ $B_RUNNING_IN_SHELL == 'true' ]];then + if [[ $B_IRC == 'false' ]];then a_color_codes=( $ANSI_COLORS ) else a_color_codes=( $IRC_COLORS ) @@ -1093,23 +1137,22 @@ select_default_color_scheme() fi # don't want these printing in irc since they show literally - if [[ $B_RUNNING_IN_SHELL != 'true' ]];then + if [[ $B_IRC == 'true' ]];then irc_clear='' fi # first make output neutral so it's just plain default for console client set_color_scheme "0" - if [[ $B_RUNNING_IN_SHELL == 'true' ]];then - print_screen_output "Welcome to $SCRIPT_NAME! Please select the default $COLOR_SELECTION color scheme." + # print_lines_basic "0" "" "" + if [[ $B_IRC == 'false' ]];then + print_lines_basic "0" "" "Welcome to $SCRIPT_NAME! Please select the default $COLOR_SELECTION 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_screen_output "Because there is no way to know your $COLOR_SELECTION foreground/background colors, you can" - print_screen_output "set your color preferences from color scheme option list below. 0 is no colors, 1 neutral." - print_screen_output "After these, there are 3 sets: 1-dark or light backgrounds; 2-light backgrounds; 3-dark backgrounds." - if [[ $B_RUNNING_IN_SHELL == 'true' ]];then - print_screen_output "Please note that this will set the $COLOR_SELECTION preferences only for user: $(whoami)" + 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." + if [[ $B_IRC == 'false' ]];then + print_lines_basic "0" "" "Please note that this will set the $COLOR_SELECTION preferences only for user: $(whoami)" fi - print_screen_output "------------------------------------------------------------------------------" + print_screen_output "$LINE1" for (( i=0; i < ${#A_COLOR_SCHEMES[@]}; i++ )) do if [[ $i -gt 9 ]];then @@ -1128,19 +1171,19 @@ select_default_color_scheme() done set_color_scheme 0 - if [[ $B_RUNNING_IN_SHELL == 'true' ]];then + if [[ $B_IRC == 'false' ]];then echo -n "" + print_screen_output "$irc_clear $i)${spacer}Remove all color settings. Restore $SCRIPT_NAME default." print_screen_output "$irc_clear $(($i+1)))${spacer}Continue, no changes or config file setting." print_screen_output "$irc_clear $(($i+2)))${spacer}Exit, use another terminal, or set manually." - print_screen_output "------------------------------------------------------------------------------" - print_screen_output "Simply type the number for the color scheme that looks best to your eyes for your $COLOR_SELECTION settings" - print_screen_output "and hit ENTER. NOTE: You can bring this option list up by starting $SCRIPT_NAME with option: -c plus one of these numbers:" - print_screen_output "94 (console, no X - $console); 95 (terminal, X - $virt_term); 96 (irc, gui, X - $irc_gui);" - print_screen_output "97 (irc, X, in terminal - $irc_x_term); 98 (irc, no X - $irc_console); 99 (global - $global)" + print_screen_output "$LINE1" + print_lines_basic "0" "" "Simply type the number for the color scheme that looks best to your eyes for your $COLOR_SELECTION settings and hit ENTER. NOTE: You can bring this option list up by starting $SCRIPT_NAME with option: -c plus one of these numbers:" + print_lines_basic "0" "" "94^(console,^no X^-^$console); 95^(terminal,^X^-^$virt_term); 96^(irc,^gui,^X^-^$irc_gui); 97^(irc,^X,^in^terminal^-^$irc_x_term); 98^(irc,^no^X^-^$irc_console); 99^(global^-^$global)" + print_lines_basic "0" "" "" print_screen_output "Your selection(s) will be stored here: $config_file" - print_screen_output "Global overrides all individual color schemes. Individual schemes remove the global setting." - print_screen_output "------------------------------------------------------------------------------" + print_lines_basic "0" "" "Global overrides all individual color schemes. Individual schemes remove the global setting." + print_screen_output "$LINE1" read user_selection if [[ -n $( grep -Es '^([0-9]+)$' <<< "$user_selection" ) && $user_selection -lt $i ]];then case $COLOR_SELECTION in @@ -1172,7 +1215,7 @@ select_default_color_scheme() touch $config_file fi if [[ -z $( grep -s "$config_variable=" $config_file ) ]];then - print_screen_output "Creating and updating config file for $COLOR_SELECTION color scheme now..." + print_lines_basic "0" "" "Creating and updating config file for $COLOR_SELECTION color scheme now..." echo "$config_variable=$user_selection" >> $config_file else print_screen_output "Updating config file for $COLOR_SELECTION color scheme now..." @@ -1194,7 +1237,7 @@ select_default_color_scheme() -e '/IRC_COLOR_SCHEME=/d' -e '/IRC_CONS_COLOR_SCHEME=/d' -e '/IRC_X_TERM_COLOR_SCHEME=/d' $config_file set_color_scheme $DEFAULT_COLOR_SCHEME elif [[ $user_selection == $(( $i+1 )) ]];then - print_screen_output "Ok, continuing $SCRIPT_NAME unchanged. You can set the colors anytime by starting with: -c 95 to 99" + print_lines_basic "0" "" "Ok, continuing $SCRIPT_NAME unchanged. You can set the colors anytime by starting with: -c 95 to 99" if [[ -n $CONSOLE_COLOR_SCHEME && -z $DISPLAY ]];then set_color_scheme $CONSOLE_COLOR_SCHEME elif [[ -n $VIRT_TERM_COLOR_SCHEME ]];then @@ -1212,9 +1255,8 @@ select_default_color_scheme() select_default_color_scheme fi else - print_screen_output "------------------------------------------------------------------------------" - print_screen_output "After finding the scheme number you like, simply run this again in a terminal to set the configuration" - print_screen_output "data file for your irc client. You can set color schemes for the following: start inxi with -c plus:" + print_screen_output "$LINE1" + print_lines_basic "0" "" "After finding the scheme number you like, simply run this again in a terminal to set the configuration data file for your irc client. You can set color schemes for the following: start inxi with -c plus:" print_screen_output "94 (console, no X - $console); 95 (terminal, X - $virt_term); 96 (irc, gui, X - $irc_gui);" print_screen_output "97 (irc, X, in terminal - $irc_x_term); 98 (irc, no X - $irc_console); 99 (global - $global)" exit 0 @@ -1417,7 +1459,7 @@ script_self_updater() local wget_error=0 file_contents='' wget_man_error=0 local man_file_path="$MAN_FILE_LOCATION/inxi.1.gz" - if [[ $B_RUNNING_IN_SHELL != 'true' ]];then + if [[ $B_IRC == 'true' ]];then print_screen_output "Sorry, you can't run the $SCRIPT_NAME self updater option (-$3) in an IRC client." exit 1 fi @@ -1449,7 +1491,7 @@ script_self_updater() if [[ -f /usr/share/man/man8/inxi.8.gz ]];then print_screen_output "Updating man page location to man1." mv -f /usr/share/man/man8/inxi.8.gz /usr/share/man/man1/inxi.1.gz - if [[ -n $( type -p mandb ) ]];then + if type -p mandb &>/dev/null;then exec $( type -p mandb ) -q fi fi @@ -1493,18 +1535,24 @@ script_self_updater() debug_data_collector() { local xiin_app='' xiin_data_file='' xiin_download='' error='' b_run_xiin='false' - local debug_data_dir='' bsd_string='' + local debug_data_dir='' bsd_string='' xorg_d_files='' xorg_file='' local completed_gz_file='' xiin_file='xiin.py' ftp_upload='ftp.techpatterns.com/incoming' local Line='-------------------------' local start_directory=$( pwd ) - + local host=$HOSTNAME + if [[ -n $host ]];then + host=${host// /-} + host="-${host,,}" + else + host="-no-host" + fi if [[ -n $BSD_TYPE ]];then - bsd_string="$BSD_TYPE-" + bsd_string="-$BSD_TYPE" fi - debug_data_dir="inxi-$bsd_string$(tr ' ' '-' <<< $HOSTNAME | tr '[A-Z]' '[a-z]' )-$1-$(date +%Y%m%d)" + debug_data_dir="inxi$bsd_string$host-$(date +%Y%m%d-%H%M%S)-$1" - if [[ $B_RUNNING_IN_SHELL == 'true' ]];then + if [[ $B_IRC == 'false' ]];then if [[ -n $ALTERNATE_FTP ]];then ftp_upload=$ALTERNATE_FTP fi @@ -1536,7 +1584,13 @@ debug_data_collector() lscpu &> $debug_data_dir/lscpu.txt lspci &> $debug_data_dir/lspci.txt + lspci -k &> $debug_data_dir/lspci-k.txt + lspci -knn &> $debug_data_dir/lspci-knn.txt lspci -n &> $debug_data_dir/lspci-n.txt + lspci -nn &> $debug_data_dir/lspci-nn.txt + lspci -mm &> $debug_data_dir/lspci-mm.txt + lspci -mmnn &> $debug_data_dir/lspci-mmnn.txt + lspci -mmnnv &> $debug_data_dir/lspci-mmnnv.txt lspci -v &> $debug_data_dir/lspci-v.txt lsusb &> $debug_data_dir/lsusb.txt ps aux &> $debug_data_dir/ps-aux.txt @@ -1629,13 +1683,17 @@ debug_data_collector() touch $debug_data_dir/no-xorg-log-file fi if [[ -e /etc/X11/xorg.conf ]];then - cp /etc/X11/xorg.conf $SCRIPT_DATA_DIR/$debug_data_dir + cat /etc/X11/xorg.conf &> $debug_data_dir/xorg-conf.txt else touch $debug_data_dir/no-xorg-conf-file fi if [[ -n $( ls /etc/X11/xorg.conf.d/ 2>/dev/null ) ]];then ls /etc/X11/xorg.conf.d &> $debug_data_dir/ls-etc-x11-xorg-conf-d.txt - cp /etc/X11/xorg.conf.d $SCRIPT_DATA_DIR/$debug_data_dir + xorg_d_files=$(ls /etc/X11/xorg.conf.d) + for xorg_file in $xorg_d_files + do + cat /etc/X11/xorg.conf.d/$xorg_file &> $debug_data_dir/xorg-conf-d-$xorg_file.txt + done else touch $debug_data_dir/no-xorg-conf-d-files fi @@ -1745,34 +1803,32 @@ debug_data_collector() check_recommends_user_output() { - local Line='-----------------------------------------------------------------------------------------' + local Line=$LINE1 local gawk_version='N/A' sed_version='N/A' sudo_version='N/A' python_version='N/A' - if [[ $B_RUNNING_IN_SHELL != 'true' ]];then + if [[ $B_IRC == 'true' ]];then print_screen_output "Sorry, you can't run this option in an IRC client." exit 1 fi initialize_paths - - echo "$SCRIPT_NAME will now begin checking for the programs it needs to operate. First a check of" - echo "the main languages and tools $SCRIPT_NAME uses. Python is only for debugging data collection." + print_lines_basic "0" "" "$SCRIPT_NAME will now begin checking for the programs it needs to operate. First a check of the main languages and tools $SCRIPT_NAME uses. Python is only for debugging data collection." echo $Line echo "Bash version: $( bash --version 2>&1 | awk 'BEGIN {IGNORECASE=1} /^GNU bash/ {print $4}' )" - if [[ -n $( type -p gawk ) ]];then + if type -p gawk &>/dev/null;then gawk_version=$( gawk --version 2>&1 | awk 'BEGIN {IGNORECASE=1} /^GNU Awk/ {print $3}' ) fi - if [[ -n $( type -p sed ) ]];then + if type -p sed &>/dev/null;then sed_version=$( sed --version 2>&1 | awk 'BEGIN {IGNORECASE=1} /^GNU sed version/ {print $4}' ) if [[ -z $sed_version ]];then # note: bsd sed shows error with --version flag sed_version=$( sed --version 2>&1 | awk 'BEGIN {IGNORECASE=1} /^sed: illegal option/ {print "BSD sed"}' ) fi fi - if [[ -n $( type -p sudo ) ]];then + if type -p sudo &>/dev/null;then sudo_version=$( sudo -V 2>&1 | awk 'BEGIN {IGNORECASE=1} /^Sudo version/ {print $3}' ) fi - if [[ -n $( type -p python ) ]];then + if type -p python &>/dev/null;then python_version=$( python --version 2>&1 | awk 'BEGIN {IGNORECASE=1} /^Python/ {print $2}' ) fi echo "Gawk version: $gawk_version" @@ -1780,26 +1836,32 @@ check_recommends_user_output() echo "Sudo version: $sudo_version" echo "Python version: $python_version" echo $Line + echo "Test One: Required System Directories." - echo "If one of these system directories is missing, $SCRIPT_NAME cannot operate:" + print_lines_basic "0" "" "If one of these system directories is missing, $SCRIPT_NAME cannot operate:" echo check_recommends_items 'required-dirs' + echo "Test Two: Required Core Applications." - echo "If one of these applications is missing, $SCRIPT_NAME cannot operate:" + print_lines_basic "0" "" "If one of these applications is missing, $SCRIPT_NAME cannot operate:" echo check_recommends_items 'required-apps' - echo 'Test Three: Script Recommends for Graphics Features. If you do not use X these do not matter.' - echo "If one of these applications is missing, $SCRIPT_NAME will have incomplete output:" + + print_lines_basic "0" "" "Test Three: Script Recommends for Graphics Features." + print_lines_basic "0" "" "NOTE: If you do not use X these do not matter (like a headless server). Otherwise, if one of these applications is missing, $SCRIPT_NAME will have incomplete output:" echo check_recommends_items 'recommended-x-apps' + echo 'Test Four: Script Recommends for Remaining Features.' - echo "If one of these applications is missing, $SCRIPT_NAME will have incomplete output:" + print_lines_basic "0" "" "If one of these applications is missing, $SCRIPT_NAME will have incomplete output:" echo check_recommends_items 'recommended-apps' + echo 'Test Five: System Directories for Various Information.' - echo "If one of these directories is missing, $SCRIPT_NAME will have incomplete output:" + print_lines_basic "0" "" "If one of these directories is missing, $SCRIPT_NAME will have incomplete output:" echo check_recommends_items 'system-dirs' + echo 'All tests completed.' } # args: $1 - check item @@ -1808,7 +1870,7 @@ check_recommends_items() local item='' item_list='' item_string='' missing_items='' missing_string='' local package='' application='' feature='' type='' starter='' finisher='' local package_deb='' package_pacman='' package_rpm='' - local print_string='' separator='' + local print_string='' separator='' width=56 local required_dirs='/proc /sys' # package-owner: 1 - debian/ubuntu; 2 - arch; 3 - yum/rpm # pardus: pisi sf -q /usr/bin/package @@ -1852,34 +1914,47 @@ check_recommends_items() /var/run/dmesg.boot:-C,-f_(BSD_only) ' + if [[ -n $COLS_INNER ]];then + if [[ $COLS_INNER -ge 90 ]];then + width=${#LINE1} # match width of $LINE1 + elif [[ $COLS_INNER -ge 78 ]];then + width=$(( $COLS_INNER - 11 )) + fi + fi + case $1 in required-dirs) item_list=$required_dirs item_string='Required file system' + item_string='' missing_string='system directories' type='directories' ;; required-apps) item_list=$required_apps item_string='Required application' + item_string='' missing_string='applications, and their corresponding packages,' type='applications' ;; recommended-x-apps) item_list=$x_recommends item_string='Recommended X application' + item_string='' missing_string='applications, and their corresponding packages,' type='applications' ;; recommended-apps) item_list=$recommended_apps item_string='Recommended application' + item_string='' missing_string='applications, and their corresponding packages,' type='applications' ;; system-dirs) item_list=$recommended_dirs item_string='System directory' + item_string='' missing_string='system directories' type='directories' ;; @@ -1912,12 +1987,12 @@ check_recommends_items() fi fi if [[ -n $feature ]];then - print_string="$item_string: $application (info: $( sed 's/_/ /g' <<< $feature ))" + print_string="$item_string$application (info: $( sed 's/_/ /g' <<< $feature ))" else - print_string="$item_string: $application" + print_string="$item_string$application" fi - starter="$( sed -e :a -e 's/^.\{1,75\}$/&./;ta' <<< $print_string )" + starter="$( sed -e :a -e 's/^.\{1,'$width'\}$/&./;ta' <<< $print_string )" if [[ -z $( grep '^/' <<< $application ) && -n $location ]] || [[ -d $application ]];then if [[ -n $location ]];then finisher=" $location" @@ -1939,21 +2014,20 @@ check_recommends_items() do application=$( cut -d ':' -f 1 <<< $item ) if [[ $type == 'applications' ]];then - # echo '--------------------------------------------------------' echo package=$( cut -d ':' -f 2 <<< $item ) package_deb=$( cut -d '~' -f 1 <<< $package ) package_pacman=$( cut -d '~' -f 2 <<< $package ) package_rpm=$( cut -d '~' -f 3 <<< $package ) echo "Application: $application" - echo "To add to your system, install the proper distribution package for your system:" - echo "Debian/Ubuntu: $package_deb :: Arch Linux: $package_pacman :: Redhat/Fedora/Suse: $package_rpm" + print_lines_basic "0" "" "To add to your system, install the proper distribution package for your system:" + print_lines_basic "0" "" "Debian/Ubuntu:^$package_deb^:: Arch Linux:^$package_pacman^:: Redhat/Fedora/Suse:^$package_rpm" else echo "Directory: $application" fi done if [[ $item_string == 'System directory' ]];then - echo "These directories are created by the kernel, so don't worry if they are not present." + print_lines_basic "0" "" "These directories are created by the kernel, so don't worry if they are not present." fi else echo "All the $( cut -d ' ' -f 1 <<< $item_string | sed -e 's/Re/re/' -e 's/Sy/sy/' ) $type are present." @@ -1972,7 +2046,8 @@ print_screen_output() { eval $LOGFS # the double quotes are needed to avoid losing whitespace in data when certain output types are used - local print_data="$( echo -e "$1" )" + # trim off whitespace at end + local print_data="$( echo -e "$1" )" # just using basic debugger stuff so you can tell which thing is printing out the data. This # should help debug kde 4 konvi issues when that is released into sid, we'll see. Turning off @@ -1991,18 +2066,14 @@ print_screen_output() print_data="P: $print_data" fi fi - if [[ $KONVI -eq 1 && $B_DCOP == 'true' ]]; then ## dcop Konversation (<= 1.1 (qt3)) # konvi doesn't seem to like \n characters, it just prints them literally $print_data="$( tr '\n' ' ' <<< "$print_data" )" dcop "$DCPORT" "$DCOPOBJ" say "$DCSERVER" "$DCTARGET" "$print_data" - elif [[ $KONVI -eq 3 && $B_QDBUS == 'true' ]]; then ## dbus Konversation (> 1.2 (qt4)) qdbus org.kde.konversation /irc say "$DCSERVER" "$DCTARGET" "$print_data" - # elif [[ $IRC_CLIENT == 'X-Chat' ]]; then # qdbus org.xchat.service print "$print_data\n" - else # the -n is needed to avoid double spacing of output in terminal echo -ne "$print_data\n" @@ -2015,7 +2086,8 @@ print_screen_output() create_print_line() { eval $LOGFS - printf "${C1}%-${INDENT}s${C2} %s" "$1" "$2" + local line=$2 + printf "${C1}%-${INDENT}s${C2} %s" "$1" "$line" eval $LOGFE } @@ -2402,7 +2474,7 @@ get_parameters() fi ;; 30) - B_RUNNING_IN_SHELL='true' + B_IRC='false' ;; 31) B_SHOW_HOST='false' @@ -2456,7 +2528,7 @@ show_options() local color_scheme_count=$(( ${#A_COLOR_SCHEMES[@]} - 1 )) local partition_string='partition' partition_string_u='Partition' - if [[ $B_RUNNING_IN_SHELL != 'true' ]];then + if [[ $B_IRC == 'true' ]];then print_screen_output "Sorry, you can't run the help option in an IRC client." exit 1 fi @@ -2470,14 +2542,13 @@ 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, 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, C, D, G, I, M, N, P, R, S, f, i, 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" "-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" "" "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):" # print_screen_output " Supported color schemes: 0-$color_scheme_count Example: $SCRIPT_NAME -c 11" # print_screen_output " Color selectors for each type display (NOTE: irc and global only show safe color set):" @@ -2487,60 +2558,60 @@ show_options() print_lines_basic "2" "97" "Console IRC running in X - like irssi in xTerm" print_lines_basic "2" "98" "Console IRC not in X" print_lines_basic "2" "99" "Global - Overrides/removes all settings. Setting specific removes global." - print_lines_basic "1" "-C" "Full CPU output, including per CPU clockspeed (if available)." + print_lines_basic "1" "-C" "CPU output, including per CPU clockspeed (if available)." print_lines_basic "1" "-d" "Optical drive data. Same as -Dd. See also -x and -xx." print_lines_basic "1" "-D" "Full hard Disk info, not only model, ie: /dev/sda ST380817AS 80.0GB. See also -x and -xx." print_lines_basic "1" "-f" "All cpu flags, triggers -C. Not shown with -F to avoid spamming. ARM cpus show 'features'." print_lines_basic "1" "-F" "Full output for $SCRIPT_NAME. Includes all Upper Case line letters, plus -s and -n. Does not show extra verbose options like -x -d -f -u -l -o -p -t -r" print_lines_basic "1" "-G" "Graphic card information (card, display server type/version, resolution, glx renderer, version)." - print_lines_basic "1" "-i" "Wan IP address, and shows local interfaces (requires ifconfig network tool). Same as -Nni. Not shown with -F for user security reasons, you shouldn't paste your local/wan IP." + print_lines_basic "1" "-i" "Wan IP address, and shows local interfaces (requires ifconfig + network tool). Same as -Nni. Not shown with -F for user security reasons, you shouldn't paste your local/wan IP." print_lines_basic "1" "-I" "Information: processes, uptime, memory, irc client (or shell type), $SCRIPT_NAME version." - print_lines_basic "1" "-l" "${partition_string_u} labels. Default: short ${partition_string} -P. For full -p output, use: -pl (or -plu)." + print_lines_basic "1" "-l" "$partition_string_u labels. Default: short $partition_string -P. For full -p output, use: -pl (or -plu)." print_lines_basic "1" "-M" "Machine data. Motherboard, Bios, and if present, System Builder (Like Lenovo). Older systems/kernels without the required /sys data can use dmidecode instead, run as root." print_lines_basic "1" "-n" "Advanced Network card information. Same as -Nn. Shows interface, speed, mac id, state, etc." print_lines_basic "1" "-N" "Network card information. With -x, shows PCI BusID, Port number." - print_lines_basic "1" "-o" "Unmounted ${partition_string} information (includes UUID and LABEL if available). Shows file system type if you have file installed, if you are root OR if you have added to /etc/sudoers (sudo v. 1.7 or newer): ALL = NOPASSWD: /usr/bin/file (sample)" - print_lines_basic "1" "-p" "Full ${partition_string} information (-P plus all other detected ${partition_string}s)." - print_lines_basic "1" "-P" "Basic ${partition_string} information (shows what -v 4 would show, but without extra data). Shows, if detected: / /boot /home /tmp /usr /var. Use -p to see all mounted ${partition_string}s." + print_lines_basic "1" "-o" "Unmounted $partition_string information (includes UUID and LABEL if available). Shows file system type if you have file installed, if you are root OR if you have added to /etc/sudoers (sudo v. 1.7 or newer) Example:^^ALL^=^NOPASSWD:^/usr/bin/file^" + print_lines_basic "1" "-p" "Full $partition_string information (-P plus all other detected ${partition_string}s)." + print_lines_basic "1" "-P" "Basic $partition_string information (shows what -v^4 would show, but without extra data). Shows, if detected: / /boot /home /tmp /usr /var. Use -p to see all mounted ${partition_string}s." print_lines_basic "1" "-r" "Distro repository data. Supported repo types: APT; PACMAN; PISI; YUM; URPMQ; Ports." print_lines_basic "1" "-R" "RAID data. Shows RAID devices, states, levels, and components, and extra data with -x/-xx. md-raid: If device is resyncing, shows resync progress line as well." print_lines_basic "1" "-s" "Sensors output (if sensors installed/configured): mobo/cpu/gpu temp; detected fan speeds. Gpu temp only for Fglrx/Nvidia drivers. Nvidia shows screen number for > 1 screens." print_lines_basic "1" "-S" "System information: host name, kernel, desktop environment (if in X), distro" - print_lines_basic "1" "-t" "Processes. Requires extra options: c (cpu) m (memory) cm (cpu+memory). If followed by numbers 1-20, shows that number of processes for each type (default:^$PS_COUNT; if in irc, max:^5): -t^cm10" + print_lines_basic "1" "-t" "Processes. Requires extra options: c^(cpu) m^(memory) cm^(cpu+memory). If followed by numbers 1-20, shows that number of processes for each type (default:^$PS_COUNT; if in irc, max:^5): -t^cm10" print_lines_basic "1" "" "Make sure to have no space between letters and numbers (-t^cm10 - right, -t^cm^10 - wrong)." - print_lines_basic "1" "-u" "${partition_string_u} UUIDs. Default: short ${partition_string} -P. For full -p output, use: -pu (or -plu)." + print_lines_basic "1" "-u" "$partition_string_u UUIDs. Default: short $partition_string -P. For full -p output, use: -pu (or -plu)." print_lines_basic "1" "-v" "Script verbosity levels. Verbosity level number is required. Should not be used with -b or -F" - print_lines_basic "1" "" "Supported levels: 0-${VERBOSITY_LEVELS} Example: $SCRIPT_NAME^-v^4" + 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" "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), ${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." + 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), $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." print_lines_basic "2" "7" "Network IP data (-i); triggers -xxx." # if distro maintainers don't want the weather feature disable it if [[ $B_ALLOW_WEATHER == 'true' ]];then print_lines_basic "1" "-w" "Local weather data/time. To check an alternate location, see: -W^. For extra weather data options see -x, -xx, and -xxx." - print_lines_basic "1" "-W " "Supported options for : postal code; city, state/country; latitude/longitude." - print_lines_basic "1" "" "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 +: new+york,ny" + print_lines_basic "1" "-W" " Supported options for : 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" "-C" "Bogomips on Cpu;" + 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): ALL = NOPASSWD: /usr/sbin/hddtemp (sample)" + 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:^^ALL^=^NOPASSWD:^/usr/sbin/hddtemp" print_lines_basic "2" "-G" "Direct rendering status for Graphics (in X)." print_lines_basic "2" "-G" "(for single gpu, nvidia driver) screen number gpu is running on." print_lines_basic "2" "-i" "IPv6 as well for LAN interface (IF) devices." print_lines_basic "2" "-I" "System GCC, default. With -xx, also show other installed GCC versions. If running in console, not in IRC client, shows shell version number, if detected. Init/RC Type and runlevel (if available)." print_lines_basic "2" "-N -A" "Version/port(s)/driver version (if available) for Network/Audio;" print_lines_basic "2" "-N -A -G" "Network, audio, graphics, shows PCI Bus ID/Usb ID number of card." - print_lines_basic "2" "-R" "md-raid: Shows component raid id. Adds second RAID Info line: raid level; report on drives (like 5/5); blocks; chunk size; bitmap (if present). Resync line, shows blocks synced/total blocks. zfs-raid: Shows raid array full size; available size; portion allocated to RAID" + print_lines_basic "2" "-R" "md-raid: Shows component raid id. Adds second RAID Info line: raid level; report on drives (like 5/5); blocks; chunk size; bitmap (if present). Resync line, shows blocks synced/total blocks. zfs-raid: Shows raid array full size; available size; portion allocated to RAID" print_lines_basic "2" "-S" "Desktop toolkit if avaliable (GNOME/XFCE/KDE only); Kernel gcc version" print_lines_basic "2" "-t" "Memory use output to cpu (-xt c), and cpu use to memory (-xt m)." if [[ $B_ALLOW_WEATHER == 'true' ]];then - print_lines_basic "2" " -w/-W" "Wind speed and time zone (-w only)." + print_lines_basic "2" "-w -W" "Wind speed and time zone (-w only)." 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." @@ -2552,13 +2623,13 @@ show_options() print_lines_basic "2" "-R" "md-raid: Superblock (if present); algorythm, U data. Adds system info line (kernel support,read ahead, raid events). If present, adds unused device line. Resync line, shows progress bar." print_lines_basic "2" "-S" "Display manager (dm) in desktop output, if in X (like kdm, gdm3, lightdm)." if [[ $B_ALLOW_WEATHER == 'true' ]];then - print_lines_basic "2" "-w/-W" "Humidity, barometric pressure." + print_lines_basic "2" "-w -W" "Humidity, barometric pressure." 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" "-S" "Panel/shell information in desktop output, if in X (like gnome-shell, cinnamon, mate-panel)." if [[ $B_ALLOW_WEATHER == 'true' ]];then - print_lines_basic "2" "-w/-W" "Location (uses -z/irc filter), weather observation time, wind chill, heat index, dew point (shows extra lines for data where relevant)." + print_lines_basic "2" "-w -W" "Location (uses -z/irc filter), weather observation time, wind chill, heat index, dew point (shows extra lines for data where relevant)." fi print_lines_basic "1" "-z" "Security filters for IP/Mac addresses, location, user home directory name. Default on for irc clients." print_lines_basic "1" "-Z" "Absolute override for output filters. Useful for debugging networking issues in irc for example." @@ -2580,12 +2651,12 @@ show_options() print_lines_basic "2" "9" "Full file/sys info logging" print_lines_basic "2" "10" "Color logging." print_lines_basic "1" "" "The following create a tar.gz file of system data, plus collecting the inxi output to file. To automatically upload debugger data tar.gz file to ftp.techpatterns.com: inxi^-xx@^<11-14>" - print_lines_basic "1" "" "For alternate ftp upload locations: Example: inxi^-!^ftp.yourserver.com/incoming^-xx@^14" + print_lines_basic "1" "" "For alternate ftp upload locations: Example:^inxi^-!^ftp.yourserver.com/incoming^-xx@^14" print_lines_basic "2" "11" "With data file of xiin read of /sys." print_lines_basic "2" "12" "With xorg conf and log data, xrandr, xprop, xdpyinfo, glxinfo etc." print_lines_basic "2" "13" "With data from dev, disks, ${partition_string}s, etc., plus xiin data file." print_lines_basic "2" "14" "Everything, full data collection." - print_lines_basic "2" "" "" + print_screen_output " " print_screen_output "Advanced Options:" print_lines_basic "1" "-! 31" "Turns off hostname in output. Useful if showing output from servers etc." print_lines_basic "1" "-! 32" "Turns on hostname in output. Overrides global B_SHOW_HOST='false'" @@ -2606,32 +2677,27 @@ show_options() print_lines_basic "1" "-! 16" "Triggers an update from svn branch GNUBSD - if present, of course." print_lines_basic "1" "-! " "Triggers an update from whatever server you list." fi - print_lines_basic "1" "-! " "Changes debugging data ftp upload location to whatever you enter here. Only used together with -xx@^11-14, and must be used in front of that. " + print_lines_basic "1" "-! " "Changes debugging data ftp upload location to whatever you enter here. Only used together with -xx@^11-14, and must be used in front of that." print_lines_basic "1" "" "Example: inxi^-!^ftp.yourserver.com/incoming^-xx@^14" fi print_screen_output " " } -# uses $COLUMNS global in terminal to set width using $LINE_MAX_BASIC +# uses $TERM_COLUMNS to set width using $COLS_MAX as max width # IMPORTANT: minimize use of subshells here or the output is too slow +# IMPORTANT: each text chunk must be a continuous line, no line breaks. For anyone who uses a +# code editor that can't do visual (not hard coded) line wrapping, upgrade to one that can. # args: $1 - 0 1 2 3 4 for indentation level; $2 -line starter, like -m; $3 - content of block. print_lines_basic() { - local line_width=$LINE_MAX_BASIC - local line_starter=$2 + local line_width=$COLS_MAX local print_string='' indent_inner='' indent_full='' indent_x='' - local indent_working='' + local indent_working='' indent_working_full='' local line_starter='' line_1_starter='' line_x_starter='' # note: to create a padded string below local fake_string=' ' temp_count='' line_count='' spacer='' - local indent_main=6 indent_x='' b_indent_x='true' - # COLUMNS is set in top globals, using tput cols - if [[ $COLUMNS -lt $LINE_MAX_BASIC ]];then - line_width=$COLUMNS - fi - case $1 in # for no options, start at left edge 0) indent_full=0 @@ -2640,9 +2706,8 @@ print_lines_basic() b_indent_x='false' ;; 1) indent_full=$indent_main - # temp_count=$( wc -c <<< $2 ) temp_count=${#2} - if [[ $temp_count -lt $indent_full ]];then + if [[ $temp_count -le $indent_full ]];then indent_working=$indent_full else indent_working=$temp_count #$(( $temp_count + 1 )) @@ -2653,10 +2718,12 @@ print_lines_basic() 2) indent_full=$(( $indent_main + 6 )) indent_inner=3 temp_count=${#2} - if [[ $temp_count -lt $indent_inner ]];then + if [[ $temp_count -le $indent_inner ]];then indent_working=$indent_inner + #indent_working_full=$indent_full else - indent_working=$temp_count #$(( $temp_count + 1 )) + indent_working=$(( $temp_count + 1 )) + #indent_working_full=$(( $indent_full - $indent_inner - 1 )) fi line_1_starter="$( sed -e :a -e "s/^.\{1,$indent_working\}$/& /;ta" <<< $2 )" line_1_starter="$( sed -e :a -e "s/^.\{1,$indent_full\}$/ &/;ta" <<< "$line_1_starter" )" @@ -2664,10 +2731,10 @@ print_lines_basic() 3) indent_full=$(( $indent_main + 8 )) indent_inner=3 temp_count=${#2} - if [[ $temp_count -lt $indent_inner ]];then + if [[ $temp_count -le $indent_inner ]];then indent_working=$indent_inner else - indent_working=$temp_count #$(( $temp_count + 1 )) + indent_working=$(( $temp_count + 1 )) fi line_1_starter="$( sed -e :a -e "s/^.\{1,$indent_working\}$/& /;ta" <<< $2 )" line_1_starter="$( sed -e :a -e "s/^.\{1,$indent_full\}$/ &/;ta" <<< "$line_1_starter" )" @@ -2691,19 +2758,13 @@ print_lines_basic() line_count=$(( $line_width - $indent_full )) - # bash loop is so slow, only run this if required - # temp_count=$( wc -c <<< $3 ) - temp_count=${#3} - # line_count=1000 - if [[ $temp_count -gt $line_count ]];then + # bash loop is slow, only run this if required + if [[ ${#3} -gt $line_count ]];then for word in $3 do temp_string="$print_string$spacer$word" spacer=' ' - # note: wc -c here will return +1 actual string length - #temp_count=$( wc -c <<< $temp_string ) - temp_count=${#temp_string} - if [[ $temp_count -lt $line_count ]];then + if [[ ${#temp_string} -lt $line_count ]];then print_string=$temp_string # lose any white space start/end # echo -n $(( $line_width - $indent_full )) else @@ -2714,7 +2775,7 @@ print_lines_basic() line_starter="$line_x_starter" fi # clean up forced connections, ie, stuff we don't want wrapping - print_string=${print_string//^/} + print_string=${print_string//\^/ } print_screen_output "$line_starter$print_string" print_string="$word$spacer" # needed to handle second word on new line temp_string='' @@ -2733,7 +2794,7 @@ print_lines_basic() else line_starter="$line_x_starter" fi - print_string=${print_string//^/} + print_string=${print_string//\^/ } print_screen_output "$line_starter$print_string" fi } @@ -2764,7 +2825,7 @@ print_version_info() local year_modified=$( gawk '{print $NF}' <<< "$last_modified" ) print_screen_output "$SCRIPT_NAME $SCRIPT_VERSION_NUMBER-$SCRIPT_PATCH_NUMBER ($last_modified)" - if [[ $B_RUNNING_IN_SHELL == 'true' ]];then + if [[ $B_IRC == 'false' ]];then print_screen_output "Program Location: $script_path" if [[ -n $script_symbolic_start ]];then print_screen_output "Started via symbolic link: $script_symbolic_start" @@ -2775,8 +2836,8 @@ print_version_info() print_screen_output " " print_lines_basic "0" "" "$SCRIPT_NAME - the universal, portable, system information tool for console and irc." print_screen_output " " - print_lines_basic "0" "" "This program started life as a fork of Infobash 3.02: Copyright (C) 2005-2007 Michiel de Boer a.k.a. locsmif." - print_lines_basic "0" "" "Subsequent changes and modifications (after Infobash 3.02): Copyright (C) 2008-$year_modified Scott Rogers, Harald Hope, aka trash80 & h2" + print_lines_basic "0" "" "This program started life as a fork of Infobash 3.02: Copyright^(C)^2005-2007^Michiel^de^Boer^a.k.a.^locsmif." + print_lines_basic "0" "" "Subsequent changes and modifications (after Infobash 3.02): Copyright^(C)^2008-${year_modified%%-*}^Harald^Hope,^Scott^Rogers,^aka^h2^&trash80." print_screen_output " " print_lines_basic "0" "" "This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. (http://www.gnu.org/licenses/gpl.html)" fi @@ -2798,7 +2859,7 @@ get_start_client() local B_Non_Native_App='false' pppid='' App_Working_Name='' local b_qt4_konvi='false' ps_parent='' - if [[ $B_RUNNING_IN_SHELL == 'true' ]];then + if [[ $B_IRC == 'false' ]];then IRC_CLIENT='Shell' unset IRC_CLIENT_VERSION # elif [[ -n $PPID ]];then @@ -2809,8 +2870,8 @@ get_start_client() Irc_Client_Path=$( readlink /proc/$PPID/exe ) # Irc_Client_Path=$( ps -p $PPID | gawk '!/[[:space:]]*PID/ {print $5}' ) # echo $( ps -p $PPID ) - irc_client_path_lower=$( tr '[:upper:]' '[:lower:]' <<< $Irc_Client_Path ) - App_Working_Name=$( basename $irc_client_path_lower ) + irc_client_path_lower=${Irc_Client_Path,,} + App_Working_Name=${irc_client_path_lower##*/} # handles the xchat/sh/bash/dash cases, and the konversation/perl cases, where clients # report themselves as perl or unknown shell. IE: when konversation starts inxi # from inside itself, as a script, the parent is konversation/xchat, not perl/bash etc @@ -2821,8 +2882,8 @@ get_start_client() pppid="$( ps -p $PPID -o ppid --no-headers | sed 's/[[:space:]]//g' )" if [[ -n $pppid && -f /proc/$pppid/exe ]];then Irc_Client_Path="$( readlink /proc/$pppid/exe )" - irc_client_path_lower="$( tr '[:upper:]' '[:lower:]' <<< $Irc_Client_Path )" - App_Working_Name=$( basename $irc_client_path_lower ) + irc_client_path_lower=${Irc_Client_Path,,} + App_Working_Name=${irc_client_path_lower##*/} B_Non_Native_App='true' fi ;; @@ -2957,7 +3018,7 @@ get_irc_client_version() B_CONSOLE_IRC='true' IRC_CLIENT="ircII" ;; - irssi-text|irssi) + irssi|irssi-text) IRC_CLIENT_VERSION=" $( $Irc_Client_Path -v | gawk 'NR == 1 { print $2 }' )" @@ -3005,7 +3066,7 @@ get_irc_client_version() # Since Konversation 1.0, the DCOP interface has changed a bit: dcop "$DCPORT" Konversation ..etc # becomes : dcop "$DCPORT" default ... or dcop "$DCPORT" irc ..etc. So we check for versions smaller # than 1 and change the DCOP parameter/object accordingly. - if [[ ${T2} -lt 1 ]];then + if [[ $T2 -lt 1 ]];then DCOPOBJ="Konversation" fi IRC_CLIENT="Konversation" @@ -3073,10 +3134,24 @@ get_irc_client_version() ;; esac ;; - weechat-curses) + supybot|limnoria) + # ff=$(nano --version);ff=( $ff );time for ((i=0;i<1000;i++)); do ff=${ff[3]};done;echo $ff + # time for ((i=0;i<1000;i++)); do ff=$(nano --version| gawk 'NR == 1 {print $4}' );done;echo $ff + # ff=$(nano --version);time for ((i=0;i<1000;i++)); do ff=$(gawk 'NR == 1 {print $4}' <<< $ff );done;echo $ff + IRC_CLIENT_VERSION=" $( $Irc_Client_Path --version | gawk 'NR == 1 { + print $2 + }' )" + if [[ -n $IRC_CLIENT_VERSION ]] && \ + [[ -n $( grep 'limnoria' <<< $IRC_CLIENT_VERSION ) || $App_Working_Name == 'limnoria' ]];then + IRC_CLIENT="Limnoria" + else + IRC_CLIENT="Supybot" + fi + ;; + weechat|weechat-curses) IRC_CLIENT_VERSION=" $( $Irc_Client_Path -v ) " B_CONSOLE_IRC='true' - IRC_CLIENT="Weechat" + IRC_CLIENT="WeeChat" ;; xchat-gnome) IRC_CLIENT_VERSION=" $( $Irc_Client_Path -v | gawk 'NR == 1 { @@ -3140,7 +3215,7 @@ set_perl_python_konvi() { if [[ -z $IRC_CLIENT_VERSION ]];then # this is a hack to try to show konversation if inxi is running but started via /cmd - if [[ -n $( grep -i 'konversation' <<< "$Ps_aux_Data" | grep -v 'grep' ) && $B_RUNNING_IN_DISPLAY == 'true' ]];then + if [[ -n $( grep -i 'konversation' <<< "$Ps_aux_Data" ) && $B_RUNNING_IN_DISPLAY == 'true' ]];then IRC_CLIENT='Konversation' IRC_CLIENT_VERSION=" $( konversation --version 2>/dev/null | gawk '/^Konversation/ {print $2}' )" B_CONSOLE_IRC='false' @@ -3227,7 +3302,7 @@ get_cmdline() get_audio_data() { eval $LOGFS - local i='' alsa_data='' audio_driver='' device_count='' temp_array='' + local i='' alsa_data='' audio_driver='' device_count='' a_temp='' IFS=$'\n' # this first step handles the drivers for cases where the second step fails to find one @@ -3345,8 +3420,8 @@ get_audio_data() if [[ ${#A_AUDIO_DATA[@]} -eq 0 ]];then A_AUDIO_DATA[0]='Failed to Detect Sound Card!' fi - temp_array=${A_AUDIO_DATA[@]} - log_function_data "A_AUDIO_DATA: $temp_array" + a_temp=${A_AUDIO_DATA[@]} + log_function_data "A_AUDIO_DATA: $a_temp" eval $LOGFE } @@ -3355,13 +3430,12 @@ get_audio_data() get_audio_usb_data() { eval $LOGFS - local usb_proc_file='' array_count='' usb_data='' usb_id='' lsusb_path='' lsusb_data='' - local temp_array='' + local usb_proc_file='' array_count='' usb_data='' usb_id='' lsusb_data='' + local a_temp='' IFS=$'\n' - lsusb_path=$( type -p lsusb ) - if [[ -n $lsusb_path ]];then - lsusb_data=$( $lsusb_path 2>/dev/null ) + if type -p lsusb &>/dev/null;then + lsusb_data=$( lsusb 2>/dev/null ) fi log_function_data 'raw' "usb_data:\n$lsusb_data" if [[ -n $lsusb_data ]];then @@ -3406,8 +3480,8 @@ get_audio_usb_data() done fi IFS="$ORIGINAL_IFS" - temp_array=${A_AUDIO_DATA[@]} - log_function_data "A_AUDIO_DATA: $temp_array" + a_temp=${A_AUDIO_DATA[@]} + log_function_data "A_AUDIO_DATA: $a_temp" eval $LOGFE } @@ -3415,7 +3489,7 @@ get_audio_usb_data() get_audio_alsa_data() { eval $LOGFS - local alsa_data='' temp_array='' + local alsa_data='' a_temp='' # now we'll get the alsa data if the file exists if [[ $B_ASOUND_VERSION_FILE == 'true' ]];then @@ -3444,8 +3518,8 @@ get_audio_alsa_data() IFS="$ORIGINAL_IFS" log_function_data 'cat' "$FILE_ASOUND_VERSION" fi - temp_array=${A_ALSA_DATA[@]} - log_function_data "A_ALSA_DATA: $temp_array" + a_temp=${A_ALSA_DATA[@]} + log_function_data "A_ALSA_DATA: $a_temp" eval $LOGFE } @@ -3491,8 +3565,8 @@ get_cpu_core_count() cpu_physical_count=1 A_CPU_CORE_DATA=( "$cpu_physical_count" "$cpu_alpha_count" "$cpu_type" "$cpu_core_count" ) fi - temp_array=${A_CPU_CORE_DATA[@]} - log_function_data "A_CPU_CORE_DATA: $temp_array" + a_temp=${A_CPU_CORE_DATA[@]} + log_function_data "A_CPU_CORE_DATA: $a_temp" eval $LOGFE } @@ -3525,7 +3599,7 @@ get_cpu_core_count_alpha() get_cpu_data() { eval $LOGFS - local i='' j='' cpu_array_nu='' a_cpu_working='' multi_cpu='' bits='' temp_array='' + local i='' j='' cpu_array_nu='' a_cpu_working='' multi_cpu='' bits='' a_temp='' local bsd_cpu_flags='' if [[ $B_CPUINFO_FILE == 'true' ]];then @@ -3644,9 +3718,9 @@ get_cpu_data() get_cpu_data_bsd fi - temp_array=${A_CPU_DATA[@]} - log_function_data "A_CPU_DATA: $temp_array" -# echo ta: ${temp_array[@]} + a_temp=${A_CPU_DATA[@]} + log_function_data "A_CPU_DATA: $a_temp" +# echo ta: ${a_temp[@]} eval $LOGFE # echo getMainCpu: ${[@]} } @@ -3661,41 +3735,44 @@ get_cpu_data_bsd() if [[ $BSD_VERSION == 'openbsd' ]];then gawk_fs='=' fi - - IFS=$'\n' - A_CPU_DATA=( $( - gawk -F "$gawk_fs" -v cpuFlags="$bsd_cpu_flags" ' - BEGIN { - IGNORECASE=1 - cpuModel="" - cpuClock="" - cpuCache="" - cpuBogomips="" - cpuVendor="" - } - /^hw.model/ { - gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF ) - gsub(/'"$BAN_LIST_CPU"'/, "", $NF ) - sub(//,"",$NF) - sub(/[a-z]+-core/, "", $NF ) - gsub(/^ +| +$|\"/, "", $NF) - gsub(/ [ \t]+/, " ", $NF) - cpuModel=$NF - if ( cpuClock != "" ) { - exit + # avoid setting this for systems where you have no read/execute permissions + # might be cases where the dmesg boot file was readable but sysctl perms failed + if [[ -n $Sysctl_a_Data || -n $bsd_cpu_flags ]];then + IFS=$'\n' + A_CPU_DATA=( $( + gawk -F "$gawk_fs" -v cpuFlags="$bsd_cpu_flags" ' + BEGIN { + IGNORECASE=1 + cpuModel="" + cpuClock="" + cpuCache="" + cpuBogomips="" + cpuVendor="" } - } - /^hw.(clock|cpuspeed)/ { - cpuClock=$NF - if ( cpuModel != "" ) { - exit + /^hw.model/ { + gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF ) + gsub(/'"$BAN_LIST_CPU"'/, "", $NF ) + sub(//,"",$NF) + sub(/[a-z]+-core/, "", $NF ) + gsub(/^ +| +$|\"/, "", $NF) + gsub(/ [ \t]+/, " ", $NF) + cpuModel=$NF + if ( cpuClock != "" ) { + exit + } } - } - END { - print cpuModel "," cpuClock "," cpuCache "," cpuFlags "," cpuBogomips "," cpuVendor - print "N/A" - }' <<< "$Sysctl_a_Data" ) ) - IFS="$ORIGINAL_IFS" + /^hw.(clock|cpuspeed)/ { + cpuClock=$NF + if ( cpuModel != "" ) { + exit + } + } + END { + print cpuModel "," cpuClock "," cpuCache "," cpuFlags "," cpuBogomips "," cpuVendor + print "N/A" + }' <<< "$Sysctl_a_Data" ) ) + IFS="$ORIGINAL_IFS" + fi eval $LOGFE } @@ -3704,27 +3781,30 @@ get_cpu_flags_bsd() { eval $LOGFS - local cpu_flags=$( gawk -F '=' ' - BEGIN { - IGNORECASE=1 - cpuFlags="" - } - /^CPU:/ { - while ( getline && !/memory/ ) { - if ( $1 ~ /Features/ ) { - # clean up odd stuff like - gsub(/<[a-z0-9]+>/,"", $2) - # all the flags are contained within < ... > on freebsd at least - gsub(/.*<|>.*/,"", $2) - gsub(/,/," ", $2) - cpuFlags = cpuFlags " " $2 - } - } - cpuFlags=tolower(cpuFlags) - print cpuFlags - exit - }' <<< "$Dmesg_Boot_Data" ) + local cpu_flags='' + if [[ -n $Dmesg_Boot_Data ]];then + cpu_flags=$( gawk -F '=' ' + BEGIN { + IGNORECASE=1 + cpuFlags="" + } + /^CPU:/ { + while ( getline && !/memory/ ) { + if ( $1 ~ /Features/ ) { + # clean up odd stuff like + gsub(/<[a-z0-9]+>/,"", $2) + # all the flags are contained within < ... > on freebsd at least + gsub(/.*<|>.*/,"", $2) + gsub(/,/," ", $2) + cpuFlags = cpuFlags " " $2 + } + } + cpuFlags=tolower(cpuFlags) + print cpuFlags + exit + }' <<< "$Dmesg_Boot_Data" ) + fi echo $cpu_flags log_function_data "$cpu_flags" eval $LOGFE @@ -3735,7 +3815,7 @@ get_cpu_ht_multicore_smp_data() { eval $LOGFS # in /proc/cpuinfo - local temp_array='' + local a_temp='' # note: known bug with xeon intel, they show a_core_id/physical_id as 0 for ht 4 core if [[ $B_CPUINFO_FILE == 'true' ]]; then @@ -3893,8 +3973,8 @@ get_cpu_ht_multicore_smp_data() } ' $FILE_CPUINFO ) ) fi - temp_array=${A_CPU_TYPE_PCNT_CCNT[@]} - log_function_data "A_CPU_TYPE_PCNT_CCNT: $temp_array" + a_temp=${A_CPU_TYPE_PCNT_CCNT[@]} + log_function_data "A_CPU_TYPE_PCNT_CCNT: $a_temp" eval $LOGFE } @@ -3951,14 +4031,14 @@ get_desktop_environment() if [[ $B_EXTRA_DATA == 'true' ]];then toolkit=$( get_de_gtk_data ) if [[ -n $toolkit ]];then - version="${version}(Gtk ${toolkit})" + version="$version(Gtk $toolkit)" fi fi desktop_environment="Unity" fi # did we find it? If not, start the xprop tests if [[ -z $desktop_environment ]];then - if [[ -n $( type -p xprop ) ]];then + if type -p xprop &>/dev/null;then xprop_root="$( xprop -root 2>/dev/null )" fi # note that cinnamon split from gnome, and and can now be id'ed via xprop, @@ -3974,7 +4054,7 @@ get_desktop_environment() if [[ $B_EXTRA_DATA == 'true' ]];then toolkit=$( get_de_gtk_data ) if [[ -n $toolkit ]];then - version="${version}(Gtk ${toolkit})" + version="$version(Gtk $toolkit)" fi fi desktop_environment="Cinnamon" @@ -3987,16 +4067,16 @@ get_desktop_environment() if [[ $B_EXTRA_DATA == 'true' ]];then toolkit=$( get_de_gtk_data ) if [[ -n $toolkit ]];then - version="${version}(Gtk ${toolkit})" + version="$version(Gtk $toolkit)" fi fi desktop_environment="MATE" # note, GNOME_DESKTOP_SESSION_ID is deprecated so we'll see how that works out # https://bugzilla.gnome.org/show_bug.cgi?id=542880 elif [[ -n $GNOME_DESKTOP_SESSION_ID ]]; then - if [[ -n $( type -p gnome-shell ) ]];then + if type -p gnome-shell &>/dev/null;then version=$( get_de_app_version 'gnome-shell' 'gnome' '3' ) - elif [[ -n $( type -p gnome-about ) ]];then + elif type -p gnome-about &>/dev/null;then version=$( get_de_app_version 'gnome-about' 'gnome' '3' ) fi if [[ $B_EXTRA_DATA == 'true' ]];then @@ -4047,7 +4127,7 @@ get_desktop_environment() fi desktop_environment="Xfce" elif [[ -n $( grep -is 'BLACKBOX_PID' <<< "$xprop_root" ) ]];then - if [[ -n $( grep -is 'fluxbox' <<< "$Ps_aux_Data" | grep -v 'grep' ) ]];then + if [[ -n $( grep -is 'fluxbox' <<< "$Ps_aux_Data" ) ]];then version=$( get_de_app_version 'fluxbox' '^fluxbox' '2' ) desktop_environment='Fluxbox' else @@ -4057,12 +4137,12 @@ get_desktop_environment() # note: openbox-lxde --version may be present, but returns openbox data version=$( get_de_app_version 'openbox' '^openbox' '2' ) if [[ $XDG_CURRENT_DESKTOP == 'LXDE' || \ - -n $( grep -is 'lxde' <<< "$Ps_aux_Data" | grep -v 'grep' ) ]];then + -n $( grep -is 'lxde' <<< "$Ps_aux_Data" ) ]];then if [[ -n $version ]];then version="(Openbox $version)" fi desktop_environment='LXDE' - elif [[ -n $( grep -is 'razor-desktop' <<< "$Ps_aux_Data" | grep -v 'grep' ) ]];then + elif [[ -n $( grep -is 'razor-desktop' <<< "$Ps_aux_Data" ) ]];then if [[ -n $version ]];then version="(Openbox $version)" fi @@ -4107,37 +4187,37 @@ get_desktop_environment() # a few manual hacks for things that don't id with xprop, these are just good guesses # note that gawk is going to exit after first occurance of search string, so no need for extra if [[ -z $desktop_environment ]];then - if [[ -n $( grep -is 'fvwm-crystal' <<< "$Ps_aux_Data" | grep -v 'grep' ) ]];then + if [[ -n $( grep -is 'fvwm-crystal' <<< "$Ps_aux_Data" ) ]];then version=$( get_de_app_version 'fvwm' '^fvwm' '2' ) desktop_environment='FVWM-Crystal' - elif [[ -n $( grep -is 'fvwm' <<< "$Ps_aux_Data" | grep -v 'grep' ) ]];then + elif [[ -n $( grep -is 'fvwm' <<< "$Ps_aux_Data" ) ]];then version=$( get_de_app_version 'fvwm' '^fvwm' '2' ) desktop_environment='FVWM' - elif [[ -n $( grep -is 'pekwm' <<< "$Ps_aux_Data" | grep -v 'grep' ) ]];then + elif [[ -n $( grep -is 'pekwm' <<< "$Ps_aux_Data" ) ]];then version=$( get_de_app_version 'pekwm' '^pekwm' '3' ) desktop_environment='pekwm' - elif [[ -n $( grep -is 'awesome' <<< "$Ps_aux_Data" | grep -v 'grep' ) ]];then + elif [[ -n $( grep -is 'awesome' <<< "$Ps_aux_Data" ) ]];then version=$( get_de_app_version 'awesome' '^awesome' '2' ) desktop_environment='Awesome' - elif [[ -n $( grep -is 'scrotwm' <<< "$Ps_aux_Data" | grep -v 'grep' ) ]];then + elif [[ -n $( grep -is 'scrotwm' <<< "$Ps_aux_Data" ) ]];then version=$( get_de_app_version 'scrotwm' '^welcome.*scrotwm' '4' ) desktop_environment='Scrotwm' # no --version for this one - elif [[ -n $( grep -is 'spectrwm' <<< "$Ps_aux_Data" | grep -v 'grep' ) ]];then + elif [[ -n $( grep -is 'spectrwm' <<< "$Ps_aux_Data" ) ]];then version=$( get_de_app_version 'spectrwm' '^spectrwm.*welcome.*spectrwm' '5' ) desktop_environment='Spectrwm' # no --version for this one - elif [[ -n $( grep -Eis '([[:space:]]|/)twm' <<< "$Ps_aux_Data" | grep -v 'grep' ) ]];then + elif [[ -n $( grep -Eis '([[:space:]]|/)twm' <<< "$Ps_aux_Data" ) ]];then desktop_environment='Twm' # no --version for this one - elif [[ -n $( grep -Eis '([[:space:]]|/)dwm' <<< "$Ps_aux_Data" | grep -v 'grep' ) ]];then + elif [[ -n $( grep -Eis '([[:space:]]|/)dwm' <<< "$Ps_aux_Data" ) ]];then version=$( get_de_app_version 'dwm' '^dwm' '1' ) desktop_environment='dwm' - elif [[ -n $( grep -is 'wmii2' <<< "$Ps_aux_Data" | grep -v 'grep' ) ]];then + elif [[ -n $( grep -is 'wmii2' <<< "$Ps_aux_Data" ) ]];then version=$( get_de_app_version 'wmii2' '^wmii2' '1' ) desktop_environment='wmii2' # note: in debian at least, wmii is actuall wmii3 - elif [[ -n $( grep -is 'wmii' <<< "$Ps_aux_Data" | grep -v 'grep' ) ]];then + elif [[ -n $( grep -is 'wmii' <<< "$Ps_aux_Data" ) ]];then version=$( get_de_app_version 'wmii' '^wmii' '1' ) desktop_environment='wmii' - elif [[ -n $( grep -Eis '([[:space:]]|/)jwm' <<< "$Ps_aux_Data" | grep -v 'grep' ) ]];then + elif [[ -n $( grep -Eis '([[:space:]]|/)jwm' <<< "$Ps_aux_Data" ) ]];then version=$( get_de_app_version 'jwm' '^jwm' '2' ) desktop_environment='JWM' fi @@ -4147,7 +4227,7 @@ get_desktop_environment() if [[ -n $version ]];then version=" $version" fi - echo "$desktop_environment${version}" + echo "$desktop_environment$version" eval $LOGFE } @@ -4177,7 +4257,7 @@ get_de_app_version() ;; # quick debian/buntu hack until I find a universal way to get version for these dash) - if [[ -n $( type -p dpkg ) ]];then + if type -p dpkg &>/dev/null;then version_data="$( dpkg -l $1 2>/dev/null )" fi ;; @@ -4235,7 +4315,7 @@ get_de_gtk_data() # this is a hack, and has to be changed with every toolkit version change, and only dev systems # have this installed, but it's a cross distro command so let's test it first - if [[ -n $( type -p pkg-config ) ]];then + if type -p pkg-config &>/dev/null;then toolkit=$( pkg-config --modversion gtk+-4.0 2>/dev/null ) # note: opensuse gets null output here, we need the command to get version and output sample if [[ -z $toolkit ]];then @@ -4250,7 +4330,7 @@ get_de_gtk_data() # we'll try some known package managers next. dpkg will handle a lot of distros # this is the most likely order as of: 2014-01-13. Not going to try to support all package managers # too much work, just the very biggest ones. - if [[ -n $( type -p dpkg ) ]];then + if type -p dpkg &>/dev/null;then toolkit=$( dpkg -s libgtk-3-0 2>/dev/null | gawk -F ':' '/^Version/ {print $2}' ) if [[ -z $toolkit ]];then toolkit=$( dpkg -s libgtk2.0-0 2>/dev/null | gawk -F ':' '/^Version/ {print $2}' ) @@ -4259,7 +4339,7 @@ get_de_gtk_data() if [[ -z $toolkit ]];then toolkit=$( dpkg -s libgtk-4-0 2>/dev/null | gawk -F ':' '/^Version/ {print $2}' ) fi - elif [[ -n $( type -p pacman ) ]];then + elif type -p pacman &>/dev/null;then toolkit=$( pacman -Qi gtk3 2>/dev/null | gawk -F ':' '/^Version/ {print $2}' ) if [[ -z $toolkit ]];then toolkit=$( pacman -Qi gtk2 2>/dev/null | gawk -F ':' '/^Version/ {print $2}' ) @@ -4276,16 +4356,17 @@ get_display_manager() { eval $LOGFS # ldm - LTSP display manager - local dm_id_list='entranced.pid entrance/entranced.pid gdm.pid gdm3.pid kdm.pid ldm.pid lightdm.pid lxdm.pid mdm.pid nodm.pid slim.lock tint2.pid wdm.pid xdm.pid' + local dm_id_list='entranced.pid gdm.pid gdm3.pid kdm.pid ldm.pid lightdm.pid lxdm.pid mdm.pid nodm.pid slim.lock tint2.pid wdm.pid xdm.pid' local dm_id='' dm='' separator='' # note we don't need to filter grep if we do it this way local x_is_running=$( grep '/usr.*/X' <<< "$Ps_aux_Data" | grep -iv '/Xprt' ) for dm_id in $dm_id_list do - if [[ -e /var/run/$dm_id || -e /run/$dm_id ]];then + # note: ${dm_id%.*}/$dm_id will create a dir name out of the dm id, then test if pid is in that + if [[ -e /run/$dm_id || -e /run/${dm_id%.*}/$dm_id || -e /var/run/$dm_id ]];then # just on the off chance that two dms are running, good info to have in that case, if possible - dm=$dm$separator$( basename $dm_id | cut -d '.' -f 1 ) + dm=$dm$separator${dm_id%.*} separator=',' fi done @@ -4308,7 +4389,7 @@ get_display_manager() get_distro_data() { eval $LOGFS - local i='' j='' distro='' distro_file='' a_distro_glob='' temp_array='' + local i='' j='' distro='' distro_file='' a_distro_glob='' a_temp='' # may need modification if archbsd / debian can be id'ed with /etc files if [[ -n $BSD_TYPE ]];then @@ -4328,11 +4409,11 @@ get_distro_data() cd "$OLDPWD" shopt -u nullglob - temp_array=${a_distro_glob[@]} - log_function_data "A_GLX_DATA: $temp_array" + a_temp=${a_distro_glob[@]} + log_function_data "A_GLX_DATA: $a_temp" if [[ ${#a_distro_glob[@]} -eq 1 ]];then - distro_file="${a_distro_glob}" + distro_file="$a_distro_glob" # use the file if it's in the known good lists elif [[ ${#a_distro_glob[@]} -gt 1 ]];then for i in $DISTROS_DERIVED $DISTROS_PRIMARY @@ -4347,12 +4428,12 @@ get_distro_data() # because Mint does not use such, it must be done as below ## this if statement requires the spaces and * as it is, else it won't work ## - if [[ " $DISTROS_LSB_GOOD " == *" ${i} "* ]] && [[ $B_LSB_FILE == 'true' ]];then + if [[ " $DISTROS_LSB_GOOD " == *" $i "* ]] && [[ $B_LSB_FILE == 'true' ]];then distro_file='lsb-release' - elif [[ " $DISTROS_OS_RELEASE_GOOD " == *" ${i} "* ]] && [[ $B_OS_RELEASE_FILE == 'true' ]];then + elif [[ " $DISTROS_OS_RELEASE_GOOD " == *" $i "* ]] && [[ $B_OS_RELEASE_FILE == 'true' ]];then distro_file='os-release' else - distro_file="${i}" + distro_file="$i" fi break fi @@ -4411,7 +4492,7 @@ get_distro_data() fi if [[ ${#distro} -gt 80 ]] && [[ $B_HANDLE_CORRUPT_DATA != 'true' ]];then - distro="${RED}/etc/${distro_file} corrupted, use -% to override${NORMAL}" + distro="${RED}/etc/$distro_file corrupted, use -% to override${NORMAL}" fi ## note: would like to actually understand the method even if it's not used # : ${distro:=Unknown distro o_O} @@ -4512,7 +4593,7 @@ get_distro_lsb_os_release_data() ;; lsb-app) # this is HORRIBLY slow, not using - if [[ -n $( type -p lsb_release ) ]];then + if type -p lsb_release &>/dev/null;then distro=$( echo "$( lsb_release -irc )" | gawk -F ':' ' BEGIN { IGNORECASE=1 @@ -4694,7 +4775,8 @@ get_dmesg_boot_data() if [[ $B_DMESG_BOOT_FILE == 'true' ]];then # replace all indented items with ~ so we can id them easily while processing - dmsg_boot_data="$( cat $FILE_DMESG_BOOT | sed $SED_RX 's/"//g' )" + # note that if user, may get error of read permissions + dmsg_boot_data="$( cat $FILE_DMESG_BOOT 2>/dev/null | sed $SED_RX 's/"//g' )" fi echo "$dmsg_boot_data" # log_function_data "$dmsg_boot_data" @@ -4715,7 +4797,7 @@ get_gcc_kernel_version() get_gcc_system_version() { eval $LOGFS - local separator='' gcc_installed='' gcc_list='' gcc_others='' temp_array='' + local separator='' gcc_installed='' gcc_list='' gcc_others='' a_temp='' local gcc_version=$( gcc --version 2>/dev/null | sed $SED_RX 's/\([^\)]*\)//g' | gawk ' BEGIN { @@ -4732,10 +4814,11 @@ get_gcc_system_version() if [[ -n $gcc_others ]];then for item in $gcc_others do - gcc_installed=$( basename $item | gawk -F '-' ' + item=${item##*/} + gcc_installed=$( gawk -F '-' ' $2 ~ /^[0-9\.]+$/ { print $2 - }' ) + }' <<< $item ) if [[ -n $gcc_installed && -z $( grep "^$gcc_installed" <<< $gcc_version ) ]];then gcc_list=$gcc_list$separator$gcc_installed separator=',' @@ -4746,8 +4829,8 @@ get_gcc_system_version() if [[ -n $gcc_version ]];then A_GCC_VERSIONS=( "$gcc_version" $gcc_list ) fi - temp_array=${A_GCC_VERSIONS[@]} - log_function_data "A_GCC_VERSIONS: $temp_array" + a_temp=${A_GCC_VERSIONS[@]} + log_function_data "A_GCC_VERSIONS: $a_temp" eval $LOGFE } get_gpu_temp_data() @@ -4755,21 +4838,26 @@ get_gpu_temp_data() local gpu_temp='' gpu_fan='' screens='' screen_nu='' gpu_temp_looper='' # we'll try for nvidia/ati, then add if more are shown - if [[ -n $( type -p nvidia-settings ) ]];then - # first get the number of screens - screens=$( nvidia-settings -q screens | gawk ' - /:[0-9]\.[0-9]/ { - screens=screens gensub(/(.*)(:[0-9]\.[0-9])(.*)/, "\\2", "1", $0) " " - } - END { - print screens - } - ' ) + if type -p nvidia-settings &>/dev/null;then + # first get the number of screens. This only work if you are in X + if [[ $B_RUNNING_IN_DISPLAY == 'true' ]];then + screens=$( nvidia-settings -q screens | gawk ' + /:[0-9]\.[0-9]/ { + screens=screens gensub(/(.*)(:[0-9]\.[0-9])(.*)/, "\\2", "1", $0) " " + } + END { + print screens + } + ' ) + else + # do a guess, this will work for most users, it's better than nothing for out of X + screens=':0.0' + fi # now we'll get the gpu temp for each screen discovered. The print out function # will handle removing screen data for single gpu systems for screen_nu in $screens do - gpu_temp_looper=$( nvidia-settings -c $screen_nu -q GPUCoreTemp | gawk -F ': ' ' + gpu_temp_looper=$( nvidia-settings -c $screen_nu -q GPUCoreTemp 2>/dev/null | gawk -F ': ' ' BEGIN { IGNORECASE=1 gpuTemp="" @@ -4787,7 +4875,7 @@ get_gpu_temp_data() screen_nu=$( cut -d ':' -f 2 <<< $screen_nu ) gpu_temp="$gpu_temp$screen_nu:$gpu_temp_looper " done - elif [[ -n $( type -p aticonfig ) ]];then + elif type -p aticonfig &>/dev/null;then # gpu_temp=$( aticonfig --adapter=0 --od-gettemperature | gawk -F ': ' ' gpu_temp=$( aticonfig --adapter=all --od-gettemperature | gawk -F ': ' ' BEGIN { @@ -4856,21 +4944,30 @@ get_graphics_agp_data() get_graphics_card_data() { eval $LOGFS - local i='' temp_array='' + local i='' a_temp='' IFS=$'\n' A_GRAPHICS_CARD_DATA=( $( gawk -F': ' ' BEGIN { IGNORECASE=1 busId="" + trueCard="" } - /vga compatible controller/ { + # not using 3D controller yet, needs research: |3D controller |display controller + # note: this is strange, but all of these can be either a separate or the same + # card. However, by comparing bus id, say: 00:02.0 we can determine that the + # cards are either the same or different. We want only the .0 version as a valid + # card. .1 would be for example: Display Adapter with bus id x:xx.1, not the right one + /vga compatible controller|3D controller|Display controller/ { gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF) gsub(/,/, " ", $NF) gsub(/^ +| +$/, "", $NF) gsub(/ [ \t]+/, " ", $NF) busId=gensub(/^([0-9a-f:\.]+) (.+)$/,"\\1","",$1) - print $NF "," busId + trueCard=gensub(/(.*)\.([0-9]+)$/,"\\2","",busId) + if ( trueCard == 0 ) { + print $NF "," busId + } }' <<< "$Lspci_v_Data" ) ) IFS="$ORIGINAL_IFS" # for (( i=0; i < ${#A_GRAPHICS_CARD_DATA[@]}; i++ )) @@ -4880,8 +4977,8 @@ get_graphics_card_data() # GFXMEM is UNUSED at the moment, because it shows AGP aperture size, which is not necessarily equal to GFX memory.. # GFXMEM="size=[$(echo "$Lspci_v_Data" | gawk '/VGA/{while (!/^$/) {getline;if (/size=[0-9][0-9]*M/) {size2=gensub(/.*\[size=([0-9]+)M\].*/,"\\1","g",$0);if (size/dev/null;then # note: MUST be this syntax: X -version 2>&1 # otherwise X -version overrides everything and this comes out null. # two knowns id strings: X.Org X Server 1.7.5 AND X Window System Version 1.7.5 #X -version 2>&1 | gawk '/^X Window System Version/ { print $5 }' x_data="$( X -version 2>&1 )" - elif [[ -n $( type -p Xorg ) ]];then + elif type -p Xorg &>/dev/null;then x_data="$( Xorg -version 2>&1)" fi if [[ -n $x_data ]];then @@ -5202,7 +5299,7 @@ get_graphics_display_server_version() get_hdd_data_basic() { eval $LOGFS - local hdd_used='' temp_array='' df_string='' + local hdd_used='' a_temp='' df_string='' local hdd_data='' df_test='' if [[ -z $BSD_TYPE ]];then @@ -5335,8 +5432,8 @@ get_hdd_data_basic() log_function_data 'cat' "$FILE_PARTITIONS" fi IFS="$ORIGINAL_IFS" - temp_array=${A_HDD_DATA[@]} - log_function_data "A_HDD_DATA: $temp_array" + a_temp=${A_HDD_DATA[@]} + log_function_data "A_HDD_DATA: $a_temp" eval $LOGFE } @@ -5345,7 +5442,7 @@ get_hard_drive_data_advanced() { eval $LOGFS local a_temp_working='' a_temp_scsi='' temp_holder='' temp_name='' i='' j='' - local sd_ls_by_id='' ls_disk_by_id='' usb_exists='' temp_array='' + local sd_ls_by_id='' ls_disk_by_id='' usb_exists='' a_temp='' ## check for all ide type drives, non libata, only do it if hdx is in array ## this is now being updated for new /sys type paths, this may handle that ok too @@ -5469,8 +5566,8 @@ get_hard_drive_data_advanced() done unset ls_disk_by_id # and then let's dump the data we don't need fi - temp_array=${A_HDD_DATA[@]} - log_function_data "A_HDD_DATA: $temp_array" + a_temp=${A_HDD_DATA[@]} + log_function_data "A_HDD_DATA: $a_temp" eval $LOGFE } @@ -5533,7 +5630,7 @@ get_init_data() { eval $LOGFS - local init_type='' init_version='' rc_type='' rc_version='' temp_array='' + local init_type='' init_version='' rc_type='' rc_version='' a_temp='' local ls_run='' strings_init_version='' local runlevel=$( get_runlevel_data ) local default_runlevel=$( get_runlevel_default ) @@ -5543,11 +5640,13 @@ get_init_data() # more data may be needed for other init systems. if [[ -e /proc/1/comm && -n $( grep -s 'systemd' /proc/1/comm ) ]];then init_type='systemd' - if [[ -n $( type -p systemd ) ]];then + if type -p systemd &>/dev/null;then init_version=$( get_de_app_version 'systemd' '^systemd' '2' ) fi - if [[ -z $init_version && -n $( type -p systemctl ) ]];then - init_version=$( get_de_app_version 'systemctl' '^systemd' '2' ) + if [[ -z $init_version ]];then + if type -p systemctl &>/dev/null;then + init_version=$( get_de_app_version 'systemctl' '^systemd' '2' ) + fi fi else ls_run=$(ls /run) @@ -5556,7 +5655,7 @@ get_init_data() init_type='Upstart' # /sbin/init --version == init (upstart 1.12.1) init_version=$( get_de_app_version 'init' 'upstart' '3' ) - elif [[ -n $( type -p epoch ) ]];then + elif type -p epoch &>/dev/null;then init_type='Epoch' # epoch version == Epoch Init System 1.0.1 "Sage" init_version=$( get_de_app_version 'epoch' '^Epoch' '4' ) @@ -5567,7 +5666,7 @@ get_init_data() # no data on version yet elif [[ -f /etc/inittab ]];then init_type='SysVinit' - if [[ -n $( type -p strings ) ]];then + if type -p strings &>/dev/null;then strings_init_version="$( strings /sbin/init | grep -E 'version[[:space:]]+[0-9]' )" fi if [[ -n $strings_init_version ]];then @@ -5581,10 +5680,10 @@ get_init_data() if [[ -n $( grep 'openrc' <<< "$ls_run" ) ]];then rc_type='OpenRC' # /sbin/openrc --version == openrc (OpenRC) 0.13 - if [[ -n $( type -p openrc ) ]];then + if type -p openrc &>/dev/null;then rc_version=$( get_de_app_version 'openrc' '^openrc' '3' ) # /sbin/rc --version == rc (OpenRC) 0.11.8 (Gentoo Linux) - elif [[ -n $( type -p rc ) ]];then + elif type -p rc &>/dev/null;then rc_version=$( get_de_app_version 'rc' '^rc' '3' ) fi ## assume sysvrc, but this data is too buggy and weird and inconsistent to have meaning @@ -5608,8 +5707,8 @@ get_init_data() IFS="$ORIGINAL_IFS" - temp_array=${A_INIT_DATA[@]} - log_function_data "A_INIT_DATA: $temp_array" + a_temp=${A_INIT_DATA[@]} + log_function_data "A_INIT_DATA: $a_temp" eval $LOGFE } @@ -5676,7 +5775,7 @@ get_lspci_chip_id() get_machine_data() { eval $LOGFS - local temp_array='' separator='' id_file='' file_data='' array_string='' + local a_temp='' separator='' id_file='' file_data='' array_string='' local id_dir='/sys/class/dmi/id/' dmi_data='' local machine_files=" sys_vendor product_name product_version product_serial product_uuid @@ -5832,9 +5931,9 @@ get_machine_data() IFS=',' A_MACHINE_DATA=( $array_string ) IFS="$ORIGINAL_IFS" - temp_array=${A_MACHINE_DATA[@]} -# echo ${temp_array[@]} - log_function_data "A_MACHINE_DATA: $temp_array" + a_temp=${A_MACHINE_DATA[@]} +# echo ${a_temp[@]} + log_function_data "A_MACHINE_DATA: $a_temp" eval $LOGFE } # B_ROOT='true';get_machine_data;exit @@ -5935,7 +6034,7 @@ get_networking_data() { eval $LOGFS - local B_USB_NETWORKING='false' temp_array='' + local B_USB_NETWORKING='false' a_temp='' IFS=$'\n' A_NETWORK_DATA=( $( @@ -6013,8 +6112,8 @@ get_networking_data() if [[ $B_SHOW_ADVANCED_NETWORK == 'true' || $B_USB_NETWORKING == 'true' ]];then get_network_advanced_data fi - temp_array=${A_NETWORK_DATA[@]} - log_function_data "A_NETWORK_DATA: $temp_array" + a_temp=${A_NETWORK_DATA[@]} + log_function_data "A_NETWORK_DATA: $a_temp" eval $LOGFE } @@ -6086,8 +6185,8 @@ get_network_advanced_data() #if [[ -n $working_path ]];then # now ls that directory and get the numeric starting sub directory and that should be the full path # to the /net directory part - dir_path=$( ls ${working_path} 2>/dev/null | grep -sE '^[0-9]' ) - working_uevent_path="${working_path}${dir_path}" + dir_path=$( ls $working_path 2>/dev/null | grep -sE '^[0-9]' ) + working_uevent_path="$working_path$dir_path" fi fi # /sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0/uevent grep for DRIVER= @@ -6240,7 +6339,7 @@ get_networking_local_ip_data() eval $LOGFS local ip_tool_command=$( type -p ip ) - local temp_array='' ip_tool='ip' ip_tool_data='' + local a_temp='' ip_tool='ip' ip_tool_data='' # the chances for all new systems to have ip by default are far higher than # the deprecated ifconfig. Only try for ifconfig if ip is not present in system if [[ -z $ip_tool_command ]];then @@ -6260,7 +6359,7 @@ get_networking_local_ip_data() # of each IF record item. Also getting rid of the unneeded numeric line starters, now it can be parsed # like ifconfig more or less elif [[ $ip_tool == 'ip' ]];then - ip_tool_data="$( eval ${ip_tool_command} | sed 's/^[0-9]\+:[[:space:]]\+/\n/' )" + ip_tool_data="$( eval $ip_tool_command | sed 's/^[0-9]\+:[[:space:]]\+/\n/' )" fi fi if [[ -z $ip_tool_command ]];then @@ -6356,8 +6455,8 @@ get_networking_local_ip_data() else A_INTERFACES_DATA=( "Interfaces program $ip_tool present but created no data. " ) fi - temp_array=${A_INTERFACES_DATA[@]} - log_function_data "A_INTERFACES_DATA: $temp_array" + a_temp=${A_INTERFACES_DATA[@]} + log_function_data "A_INTERFACES_DATA: $a_temp" eval $LOGFE } # get_networking_local_ip_data;exit @@ -6367,30 +6466,35 @@ get_optical_drive_data() { eval $LOGFS - local temp_array='' sys_uevent_path='' proc_cdrom='' link_list='' - local separator='' linked='' disk='' item_string='' proc_info_string='' - local dev_disks_links="$( ls /dev/dvd* /dev/cd* /dev/scd* 2>/dev/null )" + local a_temp='' sys_uevent_path='' proc_cdrom='' link_list='' + local separator='' linked='' working_disk='' disk='' item_string='' proc_info_string='' + local dev_disks_full="$( ls /dev/dvd* /dev/cd* /dev/scd* /dev/sr* 2>/dev/null )" + ## Not using this now because newer kernel is NOT linking all optical drives. Some, but not all + # Some systems don't support xargs -L plus the unlinked optical drive unit make this not a good option # get the actual disk dev location, first try default which is easier to run, need to preserve line breaks - local dev_disks_real="$( echo "$dev_disks_links" | xargs -L 1 readlink 2>/dev/null | sort -u )" - # Some systems don't support xargs -L so we need to do it manually - if [[ -z $dev_disks_real ]];then - for linked in $dev_disks_links - do - disk=$( readlink $linked 2>/dev/null ) - if [[ -n $disk ]];then - disk=$( basename $disk ) # puppy shows this as /dev/sr0, not sr0 - if [[ -z $dev_disks_real || -z $( grep $disk <<< $dev_disks_real ) ]];then - # need line break IFS for below, no white space - dev_disks_real="$dev_disks_real$separator$disk" - separator=$'\n' - fi - fi - done - dev_disks_real="$( sort -u <<< "$dev_disks_real" )" - linked='' - disk='' - separator='' - fi + # local dev_disks_real="$( echo "$dev_disks_full" | xargs -L 1 readlink 2>/dev/null | sort -u )" + + #echo ddl: $dev_disks_full + for working_disk in $dev_disks_full + do + disk=$( readlink $working_disk 2>/dev/null ) + if [[ -z $disk ]];then + disk=$working_disk + fi + disk=${disk##*/} # puppy shows this as /dev/sr0, not sr0 + # if [[ -z $dev_disks_real || -z $( grep $disk <<< $dev_disks_real ) ]];then + if [[ -n $disk && -z $( grep "$disk" <<< $dev_disks_real ) ]];then + # need line break IFS for below, no white space + dev_disks_real="$dev_disks_real$separator$disk" + separator=$'\n' + #separator=' ' + fi + done + dev_disks_real="$( sort -u <<< "$dev_disks_real" )" + working_disk='' + disk='' + separator='' + #echo ddr: $dev_disks_real # A_OPTICAL_DRIVE_DATA indexes: not going to use all these, but it's just as easy to build the full # data array and use what we need from it as to update it later to add features or items @@ -6409,7 +6513,7 @@ get_optical_drive_data() # 12 - dvdr # 13 - dvdram # 14 - state - + if [[ -n $dev_disks_real ]];then if [[ $B_SHOW_FULL_OPTICAL == 'true' ]];then proc_cdrom="$( cat /proc/sys/dev/cdrom/info 2>/dev/null )" @@ -6418,10 +6522,10 @@ get_optical_drive_data() A_OPTICAL_DRIVE_DATA=( $( for disk in $dev_disks_real do - for linked in $dev_disks_links + for working_disk in $dev_disks_full do - if [[ -n $( readlink $linked | grep $disk ) ]];then - linked=$( basename $linked ) + if [[ -n $( readlink $working_disk | grep $disk ) ]];then + linked=${working_disk##*/} link_list="$link_list$separator$linked" separator='~' fi @@ -6436,9 +6540,15 @@ get_optical_drive_data() rev_number='' state="" sys_path='' + working_disk='' # this is only for new sd type paths in /sys, otherwise we'll use /proc/ide if [[ -z $( grep '^hd' <<< $disk ) ]];then - sys_path=$( ls /sys/devices/pci*/*/host*/target*/*/block/$disk/uevent 2>/dev/null | sed "s|/block/$disk/uevent||" ) + # maybe newer kernels use this, not enough data. + sys_path=$( ls /sys/devices/pci*/*/ata*/host*/target*/*/block/$disk/uevent 2>/dev/null | sed "s|/block/$disk/uevent||" ) + # maybe older kernels, this used to work (2014-03-16) + if [[ -z $sys_path ]];then + sys_path=$( ls /sys/devices/pci*/*/host*/target*/*/block/$disk/uevent 2>/dev/null | sed "s|/block/$disk/uevent||" ) + fi # no need to test for errors yet, probably other user systems will require some alternate paths though if [[ -n $sys_path ]];then vendor=$( cat $sys_path/vendor 2>/dev/null ) @@ -6526,16 +6636,18 @@ get_optical_drive_data() ) ) IFS="$ORIGINAL_IFS" fi - temp_array=${A_OPTICAL_DRIVE_DATA[@]} - log_function_data "A_OPTICAL_DRIVE_DATA: $temp_array" + a_temp=${A_OPTICAL_DRIVE_DATA[@]} + # echo "$a_temp" + log_function_data "A_OPTICAL_DRIVE_DATA: $a_temp" eval $LOGFE } +# get_optical_drive_data;exit get_partition_data() { eval $LOGFS - local a_partition_working='' dev_item='' temp_array='' dev_working_item='' + local a_partition_working='' dev_item='' a_temp='' dev_working_item='' local swap_data='' df_string='' main_partition_data='' df_test='' fs_type='' local mount_data='' dev_bsd_item='' #local excluded_file_types='--exclude-type=aufs --exclude-type=tmpfs --exclude-type=iso9660' @@ -6692,9 +6804,9 @@ get_partition_data() }' ) ) IFS="$ORIGINAL_IFS" - temp_array=${A_PARTITION_DATA[@]} - # echo $temp_array - log_function_data "1: A_PARTITION_DATA:\n$temp_array" + a_temp=${A_PARTITION_DATA[@]} + # echo $a_temp + log_function_data "1: A_PARTITION_DATA:\n$a_temp" # we'll use this for older systems where no filesystem type is shown in df if [[ $BSD_TYPE == 'bsd' ]];then @@ -6724,7 +6836,7 @@ get_partition_data() fi # note: for swap this will already be set if [[ -n $( grep -E '(by-uuid|by-label)' <<< $dev_item ) ]];then - dev_working_item=$( basename $dev_item ) + dev_working_item=${dev_item##*/} if [[ -n $DEV_DISK_UUID ]];then dev_item=$( echo "$DEV_DISK_UUID" | gawk ' $0 ~ /[ /t]'$dev_working_item'[ /t]/ { @@ -6754,9 +6866,9 @@ get_partition_data() IFS="$ORIGINAL_IFS" fi done - temp_array=${A_PARTITION_DATA[@]} - # echo $temp_array - log_function_data "2: A_PARTITION_DATA:\n$temp_array" + a_temp=${A_PARTITION_DATA[@]} + # echo $a_temp + log_function_data "2: A_PARTITION_DATA:\n$a_temp" if [[ $B_SHOW_LABELS == 'true' || $B_SHOW_UUIDS == 'true' ]];then get_partition_data_advanced fi @@ -6768,7 +6880,7 @@ get_partition_data_advanced() { eval $LOGFS local a_partition_working='' dev_partition_data='' - local dev_item='' dev_label='' dev_uuid='' temp_array='' + local dev_item='' dev_label='' dev_uuid='' a_temp='' local mount_point='' # set dev disk label/mapper/uuid data globals get_partition_dev_data 'label' @@ -6852,7 +6964,7 @@ get_partition_data_advanced() dev_item=$( get_dev_processed_item "${a_partition_working[6]}" ) # make sure not to slice off rest if it's a network mounted file system if [[ -n $dev_item && -z $( grep -E '(^//|:/)' <<< $dev_item ) ]];then - dev_item=$( basename $dev_item ) ## needed to avoid error in case name still has / in it + dev_item=${dev_item##*/} ## needed to avoid error in case name still has / in it fi dev_label=${a_partition_working[7]} dev_uuid=${a_partition_working[8]} @@ -6910,9 +7022,9 @@ get_partition_data_advanced() get_partition_data_advanced_bsd fi fi - temp_array=${A_PARTITION_DATA[@]} - # echo $temp_array - log_function_data "3-advanced: A_PARTITION_DATA:\n$temp_array" + a_temp=${A_PARTITION_DATA[@]} + # echo $a_temp + log_function_data "3-advanced: A_PARTITION_DATA:\n$a_temp" eval $LOGFE } @@ -6929,7 +7041,7 @@ get_partition_data_advanced_bsd() a_partition_working=( ${A_PARTITION_DATA[i]} ) IFS="$ORIGINAL_IFS" # no need to use the rest of the name if it's not a straight /dev/item - dev_item=$( basename ${a_partition_working[6]} ) + dev_item=${a_partition_working[6]##*/} label_uuid=$( gawk -F ':' ' BEGIN { @@ -7026,7 +7138,7 @@ get_dev_processed_item() if [[ -n $DEV_DISK_MAPPER && -n $( grep -is 'mapper/' <<< $dev_item ) ]];then dev_return=$( echo "$DEV_DISK_MAPPER" | gawk ' - $( NF - 2 ) ~ /^'$( basename $dev_item )'$/ { + $( NF - 2 ) ~ /^'${dev_item##*/}'$/ { item=gensub( /..\/(.+)/, "\\1", 1, $NF ) print item }' ) @@ -7058,7 +7170,7 @@ get_pciconf_data() { eval $LOGFS - local pciconf_data='' temp_array='' + local pciconf_data='' a_temp='' if [[ $B_PCICONF == 'true' ]];then pciconf_data="$( pciconf -lv 2>/dev/null )" @@ -7136,10 +7248,8 @@ EOF" if ( device == "" ) { device=vendor } - fullLine=class "," device "," vendor "," driver "," pciId "," chipId print fullLine - }' <<< "$pciconf_data" )) IFS="$ORIGINAL_IFS" fi @@ -7147,8 +7257,8 @@ EOF" A_PCICONF_DATA='pciconf-not-installed' fi B_PCICONF_SET='true' - temp_array=${A_PCICONF_DATA[@]} - log_function_data "$temp_array" + a_temp=${A_PCICONF_DATA[@]} + log_function_data "$a_temp" log_function_data "$pciconf_data" eval $LOGFE } @@ -7260,7 +7370,7 @@ get_ps_tcm_data() esac # throttle potential irc abuse - if [[ $B_RUNNING_IN_SHELL != 'true' && $PS_COUNT -gt 5 ]];then + if [[ $B_IRC == 'true' && $PS_COUNT -gt 5 ]];then PS_THROTTLED=$PS_COUNT PS_COUNT=5 fi @@ -7468,9 +7578,9 @@ get_raid_data() fi fi B_RAID_SET='true' - temp_array=${A_RAID_DATA[@]} - log_function_data "A_RAID_DATA: $temp_array" -# echo -e "A_RAID_DATA:\n${temp_array}" + a_temp=${A_RAID_DATA[@]} + log_function_data "A_RAID_DATA: $a_temp" +# echo -e "A_RAID_DATA:\n${a_temp}" eval $LOGFE } @@ -7754,7 +7864,7 @@ $repo_data_working" # echo and execute the line breaks inserted REPO_DATA="$( echo -e $repo_data_working )" # Mandriva/Mageia using: urpmq - elif [[ -n $( type -p urpmq ) ]];then + elif type -p urpmq &>/dev/null;then REPO_DATA="$( urpmq --list-media active --list-url )" # now we need to create the structure: repo info: repo path # we do that by looping through the lines of the output and then @@ -7805,9 +7915,9 @@ get_runlevel_data() { eval $LOGFS local runlvl='' - local runlevel_path=$( type -p runlevel ) - if [[ -n $runlevel_path ]];then - runlvl="$( $runlevel_path | gawk '{ print $2 }' )" + + if type -p runlevel &>/dev/null;then + runlvl="$( runlevel | gawk '{ print $2 }' )" fi echo $runlvl eval $LOGFE @@ -7828,7 +7938,7 @@ get_runlevel_default() if [[ -L $systemd_default ]];then default_runlvl=$( readlink $systemd_default ) if [[ -n $default_runlvl ]];then - default_runlvl=$( basename $default_runlvl ) + default_runlvl=${default_runlvl##*/} fi # http://askubuntu.com/questions/86483/how-can-i-see-or-change-default-run-level # note that technically default can be changed at boot but for inxi purposes that does @@ -7856,7 +7966,7 @@ get_sensors_data() eval $LOGFS - local temp_array='' + local a_temp='' IFS=$'\n' if [[ -n $Sensors_Data ]];then @@ -8183,18 +8293,18 @@ get_sensors_data() fi IFS="$ORIGINAL_IFS" - temp_array=${A_SENSORS_DATA[@]} - log_function_data "A_SENSORS_DATA: $temp_array" + a_temp=${A_SENSORS_DATA[@]} + log_function_data "A_SENSORS_DATA: $a_temp" # echo "A_SENSORS_DATA: ${A_SENSORS_DATA[@]}" eval $LOGFE } get_sensors_output() { - local sensors_path=$( type -p sensors ) sensors_data='' + local sensors_data='' - if [[ -n $sensors_path ]];then - sensors_data="$( $sensors_path 2>/dev/null )" + if type -p sensors &>/dev/null;then + sensors_data="$( sensors 2>/dev/null )" if [[ -n "$sensors_data" ]];then # make sure the file ends in newlines then characters, the newlines are lost in the echo unless # the data ends in some characters @@ -8283,14 +8393,14 @@ get_tty_console_irc() { eval $LOGFS local tty_number='' - if [[ -n ${IRC_CLIENT} ]];then + if [[ -n $IRC_CLIENT ]];then tty_number=$( gawk ' BEGIN { IGNORECASE=1 } # if multiple irc clients open, can give wrong results # so make sure to also use the PPID number to get the right tty - /.*'$PPID'.*'${IRC_CLIENT}'/ { + /.*'$PPID'.*'$IRC_CLIENT'/ { gsub(/[^0-9]/, "", $7) print $7 exit @@ -8305,9 +8415,9 @@ get_tty_number() { eval $LOGFS - local tty_number=$( basename "$( tty 2>/dev/null )" | sed 's/[^0-9]*//g' ) - - echo $tty_number + local tty_number=$( tty 2>/dev/null | sed 's/[^0-9]*//g' ) + tty_number=${tty_number##*/} + echo ${tty_number##*/} eval $LOGFE } @@ -8450,7 +8560,7 @@ get_weather_data() local test_dir="$HOME/bin/scripts/inxi/data/weather/" local test_location='location2.xml' test_weather='weather-feed.xml' local location_data='' location='' weather_data='' location_array_value='' a_location='' - local weather_array_value='' site_elevation='' temp_array='' + local weather_array_value='' site_elevation='' a_temp='' # first we get the location data, once that is parsed and handled, we move to getting the # actual weather data, assuming no errors @@ -8711,8 +8821,8 @@ get_weather_data() echo "site_elevation: $site_elevation" echo "${A_WEATHER_DATA[1]}" fi - temp_array=${A_WEATHER_DATA[@]} - log_function_data "A_WEATHER_DATA: $temp_array" + a_temp=${A_WEATHER_DATA[@]} + log_function_data "A_WEATHER_DATA: $a_temp" eval $LOGFE } @@ -8727,10 +8837,9 @@ get_weather_data() # returns count of string length minus colors calculate_line_length() { - local string="$1" + local string=$1 # ansi:  irc: \x0312 string=$( sed -e "s/\x1b\[[0-9]\{1,2\}\(;[0-9]\{1,2\}\)\{0,2\}m//g" -e "s/\\\x0[0-9]\{1,3\}//g" <<< $string ) - # count=$( wc -c <<< $string ) count=${#string} echo $count } @@ -8784,8 +8893,7 @@ process_cpu_flags() # sse, sse2, pni = sse1,2,3,4,5 gfx extensions # svm = AMD pacifica virtualization extensions # vmx = Intel IVT (vanderpool) virtualization extensions - cpu_flags=$( - echo "$cpu_flags_working" | gawk ' + cpu_flags=$( gawk ' BEGIN { RS=" " count = 0 @@ -8814,7 +8922,7 @@ process_cpu_flags() } } print flag_string - }' ) + }' <<< "$cpu_flags_working" ) #grep -oE '\<(nx|lm|sse[0-9]?|pni|svm|vmx)\>' | tr '\n' ' ')) if [[ -z $cpu_flags ]];then @@ -8925,8 +9033,8 @@ print_short_data() model_plural='s' cpu_count_print="$cpu_physical_count " fi - - local cpu_data_string="${cpu_count_print}${cpu_core_alpha} core" + + local cpu_data_string="$cpu_count_print$cpu_core_alpha core" # local cpu_core_count=${A_CPU_CORE_DATA[0]} # load A_HDD_DATA @@ -8962,7 +9070,7 @@ print_short_data() local patch_version_number=$( get_patch_version_string ) #set_color_scheme 12 - if [[ $B_RUNNING_IN_SHELL == 'false' ]];then + if [[ $B_IRC == 'true' ]];then for i in $C1 $C2 $CN do case "$i" in @@ -8984,14 +9092,14 @@ print_short_data() #C1="${C1},1"; C2="${C2},1"; CN="${CN},1" fi fi - short_data="${C1}CPU$cpc_plural${C2}${SEP1}${cpu_data_string} ${cpu_model}$model_plural (${cpu_type}) clocked at ${min_max_clock}${SEP2}${C1}Kernel${C2}${SEP1}${current_kernel}${SEP2}${C1}Up${C2}${SEP1}${up_time}${SEP2}${C1}Mem${C2}${SEP1}${memory}${SEP2}${C1}HDD${C2}${SEP1}${hdd_capacity}($hdd_used)${SEP2}${C1}Procs${C2}${SEP1}${processes}${SEP2}" + short_data="${C1}CPU$cpc_plural${C2}$SEP1$cpu_data_string $cpu_model$model_plural ($cpu_type) clocked at $min_max_clock$SEP2${C1}Kernel${C2}$SEP1$current_kernel$SEP2${C1}Up${C2}$SEP1$up_time$SEP2${C1}Mem${C2}$SEP1$memory$SEP2${C1}HDD${C2}$SEP1$hdd_capacity($hdd_used)$SEP2${C1}Procs${C2}$SEP1$processes$SEP2" if [[ $SHOW_IRC -gt 0 ]];then - short_data="${short_data}${C1}Client${C2}${SEP1}${IRC_CLIENT}${IRC_CLIENT_VERSION}${SEP2}" + short_data="$short_data${C1}Client${C2}$SEP1$IRC_CLIENT$IRC_CLIENT_VERSION$SEP2" fi - short_data="${short_data}${C1}$SCRIPT_NAME${C2}${SEP1}$SCRIPT_VERSION_NUMBER$patch_version_number${SEP2}${CN}" + short_data="$short_data${C1}$SCRIPT_NAME${C2}$SEP1$SCRIPT_VERSION_NUMBER$patch_version_number$SEP2${CN}" if [[ $SCHEME -gt 0 ]];then - short_data="${short_data} $NORMAL" + short_data="$short_data $NORMAL" fi print_screen_output "$short_data" eval $LOGFE @@ -9031,7 +9139,7 @@ print_audio_data() else alsa_version='N/A' fi - alsa_data="${C1}Sound:${C2} $alsa ${C1}ver$SEP3${C2} $alsa_version" + alsa_data="${C1}Sound$SEP3${C2} $alsa ${C1}v:$SEP3${C2} $alsa_version" IFS="$ORIGINAL_IFS" fi # note, error handling is done in the get function, so this will never be null, but @@ -9052,7 +9160,6 @@ print_audio_data() bus_usb_text='' bus_usb_id='' print_data='' - card_id='' chip_id='' if [[ ${#A_AUDIO_DATA[@]} -gt 1 ]];then @@ -9073,7 +9180,7 @@ print_audio_data() else driver=${a_audio_working[1]} fi - audio_driver="${C1}driver$SEP3${C2} ${driver} " + audio_driver="${C1}driver$SEP3${C2} $driver " fi if [[ -n ${a_audio_working[2]} && $B_EXTRA_DATA == 'true' ]];then if [[ $( wc -w <<< ${a_audio_working[2]} ) -gt 1 ]];then @@ -9104,31 +9211,31 @@ print_audio_data() fi fi if [[ -n ${a_audio_working[0]} ]];then - card_string="${C1}Card$card_id:${C2} ${a_audio_working[0]} " + card_string="${C1}Card$card_id$EP3${C2} ${a_audio_working[0]} " audio_data="$audio_driver$port_data$pci_bus_id$chip_id" 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 $LINE_MAX ]];then + if [[ -n $alsa_data && $( calculate_line_length "$card_string$audio_data$alsa_data" ) -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 $LINE_MAX ]];then - print_data=$( create_print_line "$line_starter" "$card_string$audio_data" ) + if [[ $( calculate_line_length "$card_string$audio_data" ) -lt $COLS_INNER ]];then + print_data=$( create_print_line "$line_starter" "$card_string$audio_data${CN}" ) 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 [[ $B_EXTRA_DATA != 'true' ]];then - print_data=$( create_print_line "$line_starter" "$card_string$audio_data" ) + print_data=$( create_print_line "$line_starter" "$card_string$audio_data${CN}" ) print_screen_output "$print_data" else - print_data=$( create_print_line "$line_starter" "$card_string" ) + print_data=$( create_print_line "$line_starter" "$card_string${CN}" ) print_screen_output "$print_data" line_starter=' ' - print_data=$( create_print_line "$line_starter" "$audio_data" ) + print_data=$( create_print_line "$line_starter" "$audio_data${CN}" ) print_screen_output "$print_data" fi fi @@ -9138,7 +9245,7 @@ print_audio_data() fi if [[ -n $alsa_data ]];then alsa_data=$( sed 's/ALSA/Advanced Linux Sound Architecture/' <<< $alsa_data ) - alsa_data=$( create_print_line "$line_starter" "$alsa_data" ) + alsa_data=$( create_print_line "$line_starter" "$alsa_data${CN}" ) print_screen_output "$alsa_data" fi eval $LOGFE @@ -9152,6 +9259,8 @@ print_cpu_data() local a_cpu_working='' cpu_model='' cpu_clock='' cpu_null_error='' local cpc_plural='' cpu_count_print='' model_plural='' cpu_data_string='' local cpu_physical_count='' cpu_core_count='' cpu_core_alpha='' cpu_type='' + local cpu_2_data='' + local line_starter='' multi_cpu_starter="${C1}Clock Speeds$SEP3${C2} " ##print_screen_output "A_CPU_DATA[0]=\"${A_CPU_DATA[0]}\"" # Array A_CPU_DATA always has one extra element: max clockfreq found. @@ -9190,9 +9299,9 @@ print_cpu_data() cpu_count_print="$cpu_physical_count " model_plural='s' fi - - cpu_data_string="${cpu_count_print}${cpu_core_alpha} core" - cpu_data=$( create_print_line "CPU$cpc_plural:" "${C1}${cpu_data_string}${C2} ${a_cpu_working[0]}$model_plural (${cpu_type})" ) + line_starter="CPU$cpc_plural$SEP3" + cpu_data_string="$cpu_count_print$cpu_core_alpha core" + cpu_data="${C1}$cpu_data_string${C2} ${a_cpu_working[0]}$model_plural ($cpu_type)" if [[ $B_SHOW_CPU == 'true' ]];then # update for multicore, bogomips x core count. if [[ $B_EXTRA_DATA == 'true' ]];then @@ -9201,6 +9310,7 @@ print_cpu_data() # echo $cpu_core_count $cpu_physical_count if [[ -n ${a_cpu_working[4]} ]];then bmip_data=$( calculate_multicore_data "${a_cpu_working[4]}" "$(( $cpu_core_count * $cpu_physical_count ))" ) + bmip_data=${bmip_data%.*} fi # else # bmip_data="${a_cpu_working[4]}" @@ -9209,7 +9319,7 @@ print_cpu_data() if [[ $BSD_TYPE == 'bsd' && -z $bmip_data ]];then bmip_data='' else - bmip_data=" ${C1}bmips$SEP3${C2} $bmip_data" + bmip_data="${C1}bmips$SEP3${C2} $bmip_data " fi fi ## note: this handles how intel reports L2, total instead of per core like AMD does @@ -9226,34 +9336,53 @@ print_cpu_data() # only print shortened list if [[ $B_CPU_FLAGS_FULL != 'true' ]];then # gawk has already sorted this output, no flags returns - - cpu_flags=$( process_cpu_flags "${a_cpu_working[3]}" "${a_cpu_working[6]}" ) - cpu_flags="($cpu_flags)" - if [[ ${a_cpu_working[6]} == 'true' ]];then - flag_feature='features' + if [[ $B_EXTRA_DATA == 'true' ]];then + cpu_flags=$( process_cpu_flags "${a_cpu_working[3]}" "${a_cpu_working[6]}" ) + cpu_flags="($cpu_flags)" + if [[ ${a_cpu_working[6]} == 'true' ]];then + flag_feature='features' + fi + + cpu_flags="${C1}$flag_feature$SEP3${C2} $cpu_flags " fi - cpu_flags=" ${C1}$flag_feature$SEP3${C2} $cpu_flags" fi # arm cpus do not have flags or cache if [[ ${a_cpu_working[6]} != 'true' ]];then - cpu_data="$cpu_data${C2} ${C1}cache$SEP3${C2} $cpu_cache$cpu_flags$bmip_data${CN}" + cpu_data="$cpu_data${C2} ${C1}cache$SEP3${C2} $cpu_cache" + cpu_2_data="$cpu_flags$bmip_data" else - cpu_data="$cpu_data${C2} (ARM)$bmip_data${CN}" + cpu_data="$cpu_data${C2} (ARM)$bmip_data" fi fi # we don't this printing out extra line unless > 1 cpu core 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}" + cpu_data="$cpu_data ${C1}clocked at${C2} ${a_cpu_working[1]%.*} MHz" fi - cpu_data="$cpu_data $cpu_clock_speed" + cpu_2_data="$cpu_2_data$cpu_clock_speed" else if [[ $BSD_TYPE == 'bsd' && $B_ROOT != 'true' ]];then cpu_null_error=' No permissions for sysctl use?' fi - cpu_data=$( create_print_line "CPU:" "${C2}No CPU data available.$cpu_null_error" ) + cpu_data="${C2}No CPU data available.$cpu_null_error" + fi +# echo $cpu_data $cpu_2_data +# echo ln: $( calculate_line_length "$cpu_data $cpu_2_data" ) +# echo cpl: $( create_print_line "$line_starter" "$cpu_2_data${CN}" ): +# 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 + cpu_data=$( create_print_line "$line_starter" "$cpu_data${CN}" ) + line_starter=' ' + print_screen_output "$cpu_data" + cpu_data=$( create_print_line " " "$cpu_2_data${CN}" ) + print_screen_output "$cpu_data" + else + cpu_data=$( create_print_line "$line_starter" "$cpu_data${CN}" ) + print_screen_output "$cpu_data $cpu_2_data" fi - print_screen_output "$cpu_data" # we don't this printing out extra line unless > 1 cpu core # note the numbering, the last array item is the min/max/not found for cpu speeds if [[ ${#A_CPU_DATA[@]} -gt 2 && $B_SHOW_CPU == 'true' ]];then @@ -9263,17 +9392,26 @@ print_cpu_data() a_cpu_working=(${A_CPU_DATA[i]}) IFS="$ORIGINAL_IFS" # note: the first iteration will create a first space, for color code separation below - cpu_multi_clock_data="$cpu_multi_clock_data ${C1}$(( i + 1 )):${C2} ${a_cpu_working[1]} MHz${CN}" # someone actually appeared with a 16 core system, so going to stop the cpu core throttle # if this had some other purpose which we can't remember we'll add it back in #if [[ $i -gt 10 ]];then # break #fi + if [[ -n $cpu_multi_clock_data && \ + $( calculate_line_length "$multi_cpu_starter$cpu_multi_clock_data" ) -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='' + cpu_multi_clock_data="${C1}$(( i + 1 ))$SEP3${C2} ${a_cpu_working[1]%.*} MHz " + else + cpu_multi_clock_data="$cpu_multi_clock_data${C1}$(( i + 1 ))$SEP3${C2} ${a_cpu_working[1]%.*} MHz " + fi done - if [[ -n $cpu_multi_clock_data ]];then - cpu_multi_clock_data=$( create_print_line " " "${C1}Clock Speeds:${C2}$cpu_multi_clock_data" ) - print_screen_output "$cpu_multi_clock_data" - fi + fi + # print the last line if it exists after loop + if [[ -n $cpu_multi_clock_data ]];then + cpu_multi_clock_data=$( create_print_line " " "$multi_cpu_starter$cpu_multi_clock_data" ) + print_screen_output "$cpu_multi_clock_data" fi if [[ $B_CPU_FLAGS_FULL == 'true' ]];then print_cpu_flags_full "${a_cpu_working[3]}" "${a_cpu_working[6]}" @@ -9288,36 +9426,42 @@ print_cpu_flags_full() eval $LOGFS # note: sort only sorts lines, not words in a string, so convert to lines local cpu_flags_full="$( echo $1 | tr " " "\n" | sort )" - local a_cpu_flags='' line_starter='' temp_count='' - local i=0 counter=0 max_length=85 max_length_minus=15 flag='' flag_data='' - local line_length_max='' flag_feature='Flags' + local a_cpu_flags='' line_starter='' temp_string='' + local i=0 counter=0 starter_length=0 flag='' flag_data='' + local line_length='' flag_feature='Flags' spacer='' flag_string='' if [[ $2 == 'true' ]];then flag_feature='Features' fi - - + line_starter="CPU $flag_feature$SEP3" + starter_length=$(( ${#line_starter} + 1 )) + line_starter="${C1}$line_starter${C2} " + line_length=$(( $COLS_INNER - $starter_length )) # build the flag line array for flag in $cpu_flags_full do - a_cpu_flags[$counter]="${a_cpu_flags[$counter]}$flag " - if [[ $counter -eq 0 ]];then - line_length_max=$(( $max_length - $max_length_minus )) - else - line_length_max=$max_length + temp_string="$flag_string$spacer$flag" + spacer=' ' + # handle inner line starter + if [[ $counter -gt 0 ]];then + line_length=$COLS_INNER fi - # temp_count=$( wc -c <<< ${a_cpu_flags[$counter]} ) - temp_count=${#a_cpu_flags[$counter]} - if [[ $temp_count -gt $line_length_max ]];then + if [[ $line_length -ge ${#temp_string} ]];then + flag_string=$temp_string + else + a_cpu_flags[$counter]=$flag_string + flag_string=$flag (( counter++ )) fi + temp_string='' done + if [[ -n $flag_string ]];then + a_cpu_flags[$counter]=$flag_string + fi # then print it out for (( i=0; i < ${#a_cpu_flags[@]};i++ )) do - if [[ $i -eq 0 ]];then - line_starter="${C1}CPU $flag_feature$SEP3${C2} " - else + if [[ $i -gt 0 ]];then line_starter='' fi flag_data=$( create_print_line " " "$line_starter${a_cpu_flags[$i]}" ) @@ -9335,7 +9479,7 @@ print_graphics_data() local spacer='' driver='' driver_string='' driver_plural='' direct_render_string='' local separator_loaded='' separator_unloaded='' separator_failed='' local loaded='' unloaded='' failed='' display_server_string='' - local line_starter='Graphics:' + local line_starter='Graphics:' part_1_data='' part_2_data='' local screen_resolution="$( get_graphics_res_data )" # set A_DISPLAY_SERVER_DATA @@ -9387,38 +9531,37 @@ print_graphics_data() done fi if [[ -n $loaded ]];then - driver="${driver} $loaded" + driver="$driver $loaded" fi if [[ -n $unloaded ]];then - driver="${driver} (unloaded: $unloaded)" + driver="$driver (unloaded: $unloaded)" fi if [[ -n $failed ]];then - driver="${driver} ${RED}FAILED:${C2} $failed" + driver="$driver ${RED}FAILED$SEP3${C2} $failed" fi # sometimes for some reason there is no driver found but the array is started if [[ -z $driver ]];then driver=' N/A' fi - if [[ ${#A_GRAPHIC_DRIVERS[@]} -gt 1 ]];then driver_plural='s' fi - driver_string="${C1}driver$driver_plural$SEP3${C2}$driver " - # some basic error handling: if [[ -z $screen_resolution ]];then screen_resolution='N/A' fi + # note: fix this, we may find a display server that has no version if [[ -z $display_vendor || -z $display_version ]];then display_vendor_string="N/A" else display_vendor_string="$display_vendor $display_version" fi display_server_string="${C1}Display Server${SEP3}${C2} $display_vendor_string " + driver_string="${C1}driver$driver_plural$SEP3${C2}$driver " if [[ $B_ROOT == 'true' ]];then root_x_string='for root ' - if [[ $B_RUNNING_IN_SHELL == 'true' || $B_CONSOLE_IRC == 'true' ]];then + if [[ $B_IRC == 'false' || $B_CONSOLE_IRC == 'true' ]];then res_tty='tty size' fi fi @@ -9428,11 +9571,9 @@ print_graphics_data() fi if [[ -n $root_x_string ]];then - root_x_string="${C1}Advanced Data:${C2} N/A $root_x_string" + root_x_string="${C1}Advanced Data$SEP3${C2} N/A $root_x_string" fi - - display_full_string="$display_server_string$driver_string${C1}${res_tty}$SEP3${C2} ${screen_resolution} $root_x_string" - + if [[ ${#A_GRAPHICS_CARD_DATA[@]} -gt 0 ]];then for (( i=0; i < ${#A_GRAPHICS_CARD_DATA[@]}; i++ )) do @@ -9443,7 +9584,7 @@ print_graphics_data() card_data=${a_graphics_working[0]} if [[ $B_EXTRA_DATA == 'true' ]];then if [[ -n ${a_graphics_working[1]} ]];then - card_bus_id=" ${C1}bus-ID$SEP3${C2} ${a_graphics_working[1]}" + card_bus_id="${a_graphics_working[1]}" if [[ $B_EXTRA_EXTRA_DATA == 'true' ]];then if [[ $BSD_TYPE != 'bsd' ]];then chip_id=$( get_lspci_chip_id "${a_graphics_working[1]}" ) @@ -9452,40 +9593,70 @@ print_graphics_data() fi fi else - card_bus_id=" ${C1}bus-ID$SEP3${C2} N/A" + card_bus_id='N/A' fi fi + if [[ -n $card_bus_id ]];then + card_bus_id="${C1}bus-ID$SEP3${C2} $card_bus_id " + fi if [[ -n $chip_id ]];then - chip_id=" ${C1}chip-ID$SEP3${C2} $chip_id" + chip_id="${C1}chip-ID$SEP3${C2} $chip_id" fi if [[ ${#A_GRAPHICS_CARD_DATA[@]} -gt 1 ]];then - card_id="Card-$(($i+1)):" - else - card_id='Card:' + card_id="-$(($i+1))" fi - graphics_data="${C1}$card_id${C2} $card_data$card_bus_id$chip_id " + + part_1_data="${C1}Card$card_id$SEP3${C2} $card_data " + part_2_data="$card_bus_id$chip_id" + if [[ ${#A_GRAPHICS_CARD_DATA[@]} -gt 1 ]];then - graphics_data=$( create_print_line "$line_starter" "${graphics_data}" ) + if [[ $( calculate_line_length "$part_1_data$part_2_data" ) -gt $COLS_INNER ]];then + graphics_data=$( create_print_line "$line_starter" "$part_1_data" ) + print_screen_output "$graphics_data" + part_1_data='' + line_starter=' ' + fi + graphics_data=$( create_print_line "$line_starter" "$part_1_data$part_2_data" ) print_screen_output "$graphics_data" + part_1_data='' + part_2_data='' line_starter=' ' graphics_data='' fi done # handle cases where card detection fails, like in PS3, where lspci gives no output, or headless boxes.. else - graphics_data="${C1}Card:${C2} Failed to Detect Video Card! " + part_1_data="${C1}Card$SEP3${C2} Failed to Detect Video Card! " fi - if [[ -n $graphics_data && $( calculate_line_length "${graphics_data}$display_full_string" ) -lt $LINE_MAX ]];then - graphics_data=$( create_print_line "$line_starter" "${graphics_data}$display_full_string" ) - else - if [[ -n $graphics_data ]];then - graphics_data=$( create_print_line "$line_starter" "$graphics_data" ) + graphics_data="$part_1_data$part_2_data" + if [[ -n $graphics_data ]];then + if [[ $( calculate_line_length "$graphics_data" ) -gt $COLS_INNER ]];then + graphics_data=$( create_print_line "$line_starter" "$part_1_data" ) print_screen_output "$graphics_data" + part_1_data='' line_starter=' ' fi - graphics_data=$( create_print_line "$line_starter" "$display_full_string" ) + graphics_data=$( create_print_line "$line_starter" "$part_1_data$part_2_data" ) + print_screen_output "$graphics_data" + fi + line_starter=' ' + graphics_data='' + + part_1_data="$display_server_string$driver_string" + part_2_data="${C1}$res_tty$SEP3${C2} $screen_resolution $root_x_string" + + graphics_data="$part_1_data$part_2_data" + if [[ -n $graphics_data && $( calculate_line_length "$graphics_data" ) -gt $COLS_INNER ]];then + graphics_data=$( create_print_line "$line_starter" "$part_1_data" ) + print_screen_output "$graphics_data" + line_starter=' ' + graphics_data=$part_2_data + fi + if [[ -n $graphics_data ]];then + graphics_data=$( create_print_line "$line_starter" "$graphics_data${CN}" ) + print_screen_output "$graphics_data" + line_starter=' ' fi - print_screen_output "$graphics_data" # if [[ -z $glx_renderer || -z $glx_version ]];then # b_is_mesa='true' # fi @@ -9503,12 +9674,21 @@ print_graphics_data() glx_direct_render='N/A' fi if [[ $B_HANDLE_CORRUPT_DATA == 'true' || $B_EXTRA_DATA == 'true' ]];then - direct_render_string=" ${C1}Direct Rendering$SEP3${C2} ${glx_direct_render}${CN}" + direct_render_string=" ${C1}Direct Rendering$SEP3${C2} $glx_direct_render" fi - graphics_data="${C1}GLX Renderer$SEP3${C2} ${glx_renderer} ${C1}GLX Version$SEP3${C2} ${glx_version}${CN}$direct_render_string" - graphics_data=$( create_print_line " " "$graphics_data" ) - + part_1_data="${C1}GLX Renderer$SEP3${C2} $glx_renderer " + part_2_data="${C1}GLX 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 + graphics_data=$( create_print_line "$line_starter" "$part_1_data" ) + print_screen_output "$graphics_data" + part_1_data='' + line_starter=' ' + #echo 1 + fi + graphics_data=$( create_print_line "$line_starter" "$part_1_data$part_2_data" ) print_screen_output "$graphics_data" + #echo 2 fi eval $LOGFE } @@ -9579,19 +9759,19 @@ print_hard_disk_data() fi hdd_name="${C1}model$SEP3${C2} $hdd_name_temp" hdd_string="$usb_data$dev_data$hdd_name$size_data$hdd_serial$hdd_temp_data" - hdd_model="${hdd_model}${C1}$(($i+1)):${C2} $hdd_string " + hdd_model="$hdd_model${C1}$(($i+1))$SEP3${C2} $hdd_string " # printing line one, then new lines according to $divisor setting, and after, if leftovers, print that line. case $i in 0) if [[ $divisor -eq 1 ]];then - hdd_data=$( create_print_line "$Line_Starter" "${C1}HDD Total Size:${C2} ${hdd_capacity} (${hdd_used})" ) + hdd_data=$( create_print_line "$Line_Starter" "${C1}HDD Total Size$SEP3${C2} $hdd_capacity ($hdd_used)" ) print_screen_output "$hdd_data" Line_Starter=' ' - hdd_data=$( create_print_line "$Line_Starter" "${hdd_model}" ) + hdd_data=$( create_print_line "$Line_Starter" "$hdd_model" ) print_screen_output "$hdd_data" hdd_model='' else - hdd_data=$( create_print_line "$Line_Starter" "${C1}HDD Total Size:${C2} ${hdd_capacity} (${hdd_used}) ${hdd_model}" ) + hdd_data=$( create_print_line "$Line_Starter" "${C1}HDD Total Size$SEP3${C2} $hdd_capacity ($hdd_used) $hdd_model" ) print_screen_output "$hdd_data" hdd_model='' Line_Starter=' ' @@ -9600,7 +9780,7 @@ print_hard_disk_data() *) # using modulus here, if divisible by $divisor, print line, otherwise skip if [[ $(( $i % $divisor )) -eq 0 ]];then - hdd_data=$( create_print_line "$Line_Starter" "${hdd_model}${CN}" ) + hdd_data=$( create_print_line "$Line_Starter" "$hdd_model" ) print_screen_output "$hdd_data" hdd_model='' Line_Starter=' ' @@ -9610,7 +9790,7 @@ print_hard_disk_data() done # then print any leftover items if [[ -n $hdd_model ]];then - hdd_data=$( create_print_line "$Line_Starter" "${hdd_model}${CN}" ) + hdd_data=$( create_print_line "$Line_Starter" "$hdd_model${CN}" ) print_screen_output "$hdd_data" fi # temporary message to indicate not yet supported @@ -9622,7 +9802,7 @@ print_hard_disk_data() fi else # temporary message to indicate not yet supported - hdd_data="${C1}HDD Total Size:${C2} ${hdd_capacity} (${hdd_used})" + hdd_data="${C1}HDD Total Size$SEP3${C2} $hdd_capacity ($hdd_used)" if [[ $BSD_TYPE == 'bsd' ]];then hdd_data=$bsd_unsupported fi @@ -9663,12 +9843,13 @@ print_info_data() gcc_installed='N/A' fi if [[ $B_EXTRA_EXTRA_DATA == 'true' && -n ${A_GCC_VERSIONS[1]} ]];then - gcc_others=" ${C1}alt$SEP3${C2} $( tr ',' '/' <<< ${A_GCC_VERSIONS[1]} )" + # gcc_others=" ${C1}alt$SEP3${C2} $( tr ',' '/' <<< ${A_GCC_VERSIONS[1]} )" + gcc_others=" ${C1}alt$SEP3${C2} ${A_GCC_VERSIONS[1]//,//}" fi gcc_installed="${C1}Gcc sys$SEP3${C2} $gcc_installed$gcc_others " fi fi - if [[ $B_RUNNING_IN_SHELL == 'true' ]];then + if [[ $B_IRC == 'false' ]];then shell_data=$( get_shell_data ) if [[ -n $shell_data ]];then # note, if you start this in tty, it will give 'login' as the parent, which we don't want. @@ -9690,8 +9871,8 @@ print_info_data() fi # Some code could look superfluous but BitchX doesn't like lines not ending in a newline. F*&k that bitch! - # long_last=$( echo -ne "${C1}Processes$SEP3${C2} ${processes}${CN} | ${C1}Uptime$SEP3${C2} ${up_time}${CN} | ${C1}Memory$SEP3${C2} ${MEM}${CN}" ) - info_data="${C1}Processes$SEP3${C2} ${processes} ${C1}Uptime$SEP3${C2} ${up_time} ${C1}Memory$SEP3${C2} ${memory}${CN} " + # long_last=$( echo -ne "${C1}Processes$SEP3${C2} $processes${CN} | ${C1}Uptime$SEP3${C2} $up_time${CN} | ${C1}Memory$SEP3${C2} $MEM${CN}" ) + info_data="${C1}Processes$SEP3${C2} $processes ${C1}Uptime$SEP3${C2} $up_time ${C1}Memory$SEP3${C2} $memory " # this only triggers if no X data is present or if extra data switch is on if [[ $B_SHOW_DISPLAY_DATA != 'true' || $B_EXTRA_DATA == 'true' ]];then @@ -9716,9 +9897,6 @@ print_info_data() fi runlvl_default=${A_INIT_DATA[5]} - if [[ -z $runlvl_default ]];then - runlvl_default='N/A' - fi fi # currently only using openrc here, otherwise show nothing rc_type=${A_INIT_DATA[2]} @@ -9737,43 +9915,50 @@ print_info_data() init_data="$init_type$rc_type$runlvl$runlvl_default" fi if [[ $SHOW_IRC -gt 0 ]];then - client_data="${C1}Client$SEP3${C2} ${IRC_CLIENT}${IRC_CLIENT_VERSION} " + client_data="${C1}Client$SEP3${C2} $IRC_CLIENT$IRC_CLIENT_VERSION " fi - info_data="${info_data}" - closing_data="$client_data${C1}$SCRIPT_NAME$SEP3${C2} $SCRIPT_VERSION_NUMBER$patch_version_number${CN}" - + # info_data="$info_data" + closing_data="$client_data${C1}$SCRIPT_NAME$SEP3${C2} $SCRIPT_VERSION_NUMBER$patch_version_number" # 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}${closing_data}" ) -gt $LINE_MAX ]];then - info_data=${info_data}${init_data} - info_data=$( create_print_line "$line_starter" "$info_data" ) + if [[ $( calculate_line_length "$info_data$init_data$gcc_installed" ) -gt $COLS_INNER ]];then + # info_data=$info_data + info_data=$( create_print_line "$line_starter" "$info_data${CN}" ) print_screen_output "$info_data" - init_data='' info_data='' # closing_data='' line_starter=' ' #echo 1 fi - if [[ $( calculate_line_length "${info_data}${init_data}${gcc_installed}${closing_data}" ) -gt $LINE_MAX ]];then - info_data=${info_data}${init_data}${gcc_installed} - info_data=$( create_print_line "$line_starter" "$info_data" ) + if [[ $( calculate_line_length "$init_data$gcc_installed" ) -gt $COLS_INNER ]];then + info_data=$init_data + info_data=$( create_print_line "$line_starter" "$info_data${CN}" ) + print_screen_output "$info_data" + info_data='' + init_data='' + line_starter=' ' + #echo 2 + fi + if [[ $( calculate_line_length "$info_data$init_data$gcc_installed$closing_data" ) -gt $COLS_INNER ]];then + info_data=$info_data$init_data$gcc_installed + info_data=$( create_print_line "$line_starter" "$info_data${CN}" ) print_screen_output "$info_data" info_data='' gcc_installed='' init_data='' line_starter=' ' - #echo 2 + #echo 3 fi - info_data="${info_data}${init_data}${gcc_installed}${closing_data}" + info_data="$info_data$init_data$gcc_installed$closing_data" - info_data=$( create_print_line "$line_starter" "$info_data" ) + info_data=$( create_print_line "$line_starter" "$info_data${CN}" ) if [[ $SCHEME -gt 0 ]];then - info_data="${info_data} ${NORMAL}" + info_data="$info_data ${NORMAL}" fi print_screen_output "$info_data" eval $LOGFE } - +#print_info_data;exit print_machine_data() { eval $LOGFS @@ -9835,7 +10020,7 @@ print_machine_data() chassis_type=" ${C1}type$SEP3${C2} ${A_MACHINE_DATA[13]}" fi if [[ -n ${A_MACHINE_DATA[14]} ]];then - chassis_version=" ${C1}version$SEP3${C2} ${A_MACHINE_DATA[14]}" + chassis_version=" ${C1}v$SEP3${C2} ${A_MACHINE_DATA[14]}" fi if [[ -n ${A_MACHINE_DATA[15]} && $B_OUTPUT_FILTER != 'true' ]];then chassis_serial=" ${C1}serial$SEP3${C2} ${A_MACHINE_DATA[15]}" @@ -9856,7 +10041,7 @@ print_machine_data() mobo_model='N/A' fi if [[ -n ${A_MACHINE_DATA[7]} ]];then - mobo_version=" ${C1}version$SEP3${C2} ${A_MACHINE_DATA[7]}" + mobo_version=" ${C1}v$SEP3${C2} ${A_MACHINE_DATA[7]}" fi if [[ -n ${A_MACHINE_DATA[8]} && $B_OUTPUT_FILTER != 'true' ]];then mobo_serial=" ${C1}serial$SEP3${C2} ${A_MACHINE_DATA[8]}" @@ -9883,8 +10068,8 @@ print_machine_data() bios_rom=" ${C1}rom size$SEP3${C2} ${A_MACHINE_DATA[17]}" fi mobo_line="${C1}Mobo$SEP3${C2} $mobo_vendor ${C1}model$SEP3${C2} $mobo_model$mobo_version$mobo_serial" - bios_line="${C1}Bios$SEP3${C2} $bios_vendor ${C1}version$SEP3${C2} $bios_version ${C1}date$SEP3${C2} $bios_date$bios_rom" - if [[ $( calculate_line_length "$mobo_line$bios_line" ) -lt $LINE_MAX ]];then + bios_line="${C1}Bios$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 mobo_line="$mobo_line $bios_line" bios_line='' fi @@ -9903,44 +10088,44 @@ print_machine_data() product_name='N/A' fi if [[ -n ${A_MACHINE_DATA[2]} ]];then - product_version=" ${C1}version$SEP3${C2} ${A_MACHINE_DATA[2]}" + product_version=" ${C1}v$SEP3${C2} ${A_MACHINE_DATA[2]}" fi if [[ -n ${A_MACHINE_DATA[3]} && $B_OUTPUT_FILTER != 'true' ]];then product_serial=" ${C1}serial$SEP3${C2} ${A_MACHINE_DATA[3]} " fi system_line="${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 $LINE_MAX ]];then + if [[ -n $chassis_line && $( calculate_line_length "$system_line$chassis_line" ) -lt $COLS_INNER ]];then system_line="$system_line $chassis_line" chassis_line='' fi fi IFS="$ORIGINAL_IFS" else - system_line="${C2}$sysDmiNull${CN}" + system_line="${C2}$sysDmiNull" fi # patch to dump all of above if dmidecode was data source and non root user if [[ ${A_MACHINE_DATA[0]} == 'dmidecode-non-root-user' || ${A_MACHINE_DATA[0]} == 'dmidecode-no-smbios-dmi-data' ]];then if [[ ${A_MACHINE_DATA[0]} == 'dmidecode-non-root-user' ]];then - system_line="${C2}${sysDmiError}dmidecode: you must be root to run dmidecode${CN}" + system_line="${C2}${sysDmiError}dmidecode: you must be root to run dmidecode" elif [[ ${A_MACHINE_DATA[0]} == 'dmidecode-no-smbios-dmi-data' ]];then - system_line="${C2}${sysDmiError}dmidecode: no machine data available${CN}" + system_line="${C2}${sysDmiError}dmidecode: no machine data available" fi mobo_line='' bios_line='' chassis_line='' fi - system_line=$( create_print_line "Machine:" "$system_line" ) + system_line=$( create_print_line "Machine:" "$system_line${CN}" ) print_screen_output "$system_line" if [[ -n $mobo_line ]];then - mobo_line=$( create_print_line " " "$mobo_line" ) + mobo_line=$( create_print_line " " "$mobo_line${CN}" ) print_screen_output "$mobo_line" fi if [[ -n $bios_line ]];then - bios_line=$( create_print_line " " "$bios_line" ) + bios_line=$( create_print_line " " "$bios_line${CN}" ) print_screen_output "$bios_line" fi if [[ -n $chassis_line ]];then - chassis_line=$( create_print_line " " "$chassis_line" ) + chassis_line=$( create_print_line " " "$chassis_line${CN}" ) print_screen_output "$chassis_line" fi @@ -9958,8 +10143,8 @@ print_module_version() if [[ -z $( grep -E '^snd' <<< $modules ) ]];then prefix='snd_' # sound modules start with snd_ fi - modules=$( tr '[A-Z]' '[a-z]' <<< $modules ) - modules=$( tr '-' '_' <<< $modules ) + modules=${modules,,} + modules=${modules//-/_} # special intel processing, generally no version info though if [[ $modules == 'hda intel' ]];then modules='hda_intel' @@ -9977,7 +10162,7 @@ print_module_version() done if [[ -n $module_versions ]];then - echo " ${C1}ver$SEP3${C2}$module_versions" + echo " ${C1}v$SEP3${C2}$module_versions" fi eval $LOGFE } @@ -10017,11 +10202,10 @@ print_networking_data() pci_bus_id='' port_data='' port_plural='' - card_id='' chip_id='' if [[ ${#A_NETWORK_DATA[@]} -gt 1 ]];then - chip_id="-$(( $i + 1 ))" + card_id="-$(( $i + 1 ))" fi if [[ -n ${a_network_working[1]} && $B_EXTRA_DATA == 'true' && $BSD_TYPE != 'bsd' ]];then module_version=$( print_module_version "${a_network_working[1]}" ) @@ -10033,7 +10217,7 @@ print_networking_data() else driver=${a_network_working[1]} fi - driver_data="${C1}driver$SEP3${C2} ${driver}$module_version " + driver_data="${C1}driver$SEP3${C2} $driver$module_version " fi if [[ -n ${a_network_working[2]} && $B_EXTRA_DATA == 'true' ]];then if [[ $( wc -w <<< ${a_network_working[2]} ) -gt 1 ]];then @@ -10064,15 +10248,15 @@ print_networking_data() chip_id=" ${C1}chip-ID$SEP3${C2} $chip_id" fi fi - card_string="${C1}Card$card_id:${C2} ${a_network_working[0]} " + card_string="${C1}Card$card_id$SEP3${C2} ${a_network_working[0]} " card_data="$driver_data$port_data$pci_bus_id$chip_id" - if [[ $( calculate_line_length "$card_string$card_data" ) -gt $LINE_MAX ]];then - network_data=$( create_print_line "$line_starter" "$card_string" ) + if [[ $( calculate_line_length "$card_string$card_data" ) -gt $COLS_INNER ]];then + network_data=$( create_print_line "$line_starter" "$card_string${CN}" ) line_starter=' ' card_string='' print_screen_output "$network_data" fi - network_data=$( create_print_line "$line_starter" "$card_string$card_data" ) + network_data=$( create_print_line "$line_starter" "$card_string$card_data${CN}" ) line_starter=' ' print_screen_output "$network_data" if [[ $B_SHOW_ADVANCED_NETWORK == 'true' ]];then @@ -10080,8 +10264,8 @@ print_networking_data() fi done else - network_data="${C1}Card:${C2} Failed to Detect Network Card! " - network_data=$( create_print_line "$line_starter" "$network_data" ) + network_data="${C1}Card$SEP3${C2} Failed to Detect Network Card! " + network_data=$( create_print_line "$line_starter" "$network_data${CN}" ) print_screen_output "$network_data" fi if [[ $B_SHOW_IP == 'true' ]];then @@ -10131,8 +10315,8 @@ print_network_advanced_data() mac_id=${a_network_working[9]} fi fi - network_data="${C1}IF:${C2} $if_id ${C1}state$SEP3${C2} $oper_state $speed_string$duplex_string${C1}mac$SEP3${C2} $mac_id" - network_data=$( create_print_line " " "$network_data" ) + network_data="${C1}IF$SEP3${C2} $if_id ${C1}state$SEP3${C2} $oper_state $speed_string$duplex_string${C1}mac$SEP3${C2} $mac_id" + network_data=$( create_print_line " " "$network_data${CN}" ) print_screen_output "$network_data" eval $LOGFE @@ -10145,7 +10329,7 @@ print_networking_ip_data() local wan_ip_data='' a_interfaces_working='' interfaces='' i='' local if_id='' if_ip='' if_ipv6='' if_ipv6_string='' full_string='' if_string='' local if_id_string='' if_ip_string='' - local line_max=$(( $LINE_MAX - 50 )) + local line_max=$(( $COLS_INNER - 40 )) # set A_INTERFACES_DATA get_networking_local_ip_data @@ -10157,7 +10341,7 @@ print_networking_ip_data() ip=$FILTER_STRING fi fi - wan_ip_data="${C1}WAN IP:${C2} $ip " + wan_ip_data="${C1}WAN IP$SEP3${C2} $ip " # then create the list of local interface/ip i=0 ## loop starts with 1 by auto-increment so it only shows cards > 1 while [[ -n ${A_INTERFACES_DATA[i]} ]] @@ -10192,10 +10376,10 @@ print_networking_ip_data() if [[ -n ${a_interfaces_working[0]} ]];then if_id=${a_interfaces_working[0]} fi - if_string="$wan_ip_data$if_string${C1}IF:${C2} $if_id$if_ip_string$if_ipv6_string " + if_string="$wan_ip_data$if_string${C1}IF$SEP3${C2} $if_id$if_ip_string$if_ipv6_string " wan_ip_data='' if [[ $( calculate_line_length "$if_string" ) -gt $line_max ]];then - full_string=$( create_print_line " " "$if_string" ) + full_string=$( create_print_line " " "$if_string${CN}" ) print_screen_output "$full_string" if_string='' fi @@ -10204,7 +10388,7 @@ print_networking_ip_data() # then print out anything not printed already if [[ -n $if_string ]];then - full_string=$( create_print_line " " "$if_string" ) + full_string=$( create_print_line " " "$if_string${CN}" ) print_screen_output "$full_string" fi eval $LOGFE @@ -10280,8 +10464,8 @@ print_optical_drive_data() fi drive_string="$drive_id ${C1}model$SEP3${C2} $vendor$rev ${C1}dev-links$SEP3${C2} $drive_links" fi - drive_data="${C1}Optical${counter}:${C2} $drive_string" - drive_data=$( create_print_line "$Line_Starter" "$drive_data" ) + drive_data="${C1}Optical${counter}$SEP3${C2} $drive_string" + drive_data=$( create_print_line "$Line_Starter" "$drive_data${CN}" ) print_screen_output "$drive_data" Line_Starter=' ' # 5 - speed @@ -10336,15 +10520,15 @@ print_optical_drive_data() separator=',' fi if [[ -n ${a_drives[10]} && ${a_drives[10]} == 1 ]];then - rw_support="${rw_support}${separator}cd-rw" + rw_support="$rw_support${separator}cd-rw" separator=',' fi if [[ -n ${a_drives[12]} && ${a_drives[12]} == 1 ]];then - rw_support="${rw_support}${separator}dvd-r" + rw_support="$rw_support${separator}dvd-r" separator=',' fi if [[ -n ${a_drives[13]} && ${a_drives[13]} == 1 ]];then - rw_support="${rw_support}${separator}dvd-ram" + rw_support="$rw_support${separator}dvd-ram" separator=',' fi if [[ -z $rw_support ]];then @@ -10352,7 +10536,7 @@ print_optical_drive_data() fi drive_data="${C1}Features: speed$SEP3${C2} $speed$multisession$audio ${C1}dvd$SEP3${C2} $dvd ${C1}rw$SEP3${C2} $rw_support$state" - drive_data=$( create_print_line "$Line_Starter" "$drive_data" ) + drive_data=$( create_print_line "$Line_Starter" "$drive_data${CN}" ) print_screen_output "$drive_data" fi done @@ -10366,9 +10550,9 @@ print_partition_data() { eval $LOGFS local a_partition_working='' partition_used='' partition_data='' - local counter=0 i=0 a_partition_data='' line_starter='' line_max=$(( $LINE_MAX - 35 )) + local counter=0 i=0 a_partition_data='' line_starter='' line_max=$(( $COLS_INNER - 25 )) local partitionIdClean='' part_dev='' full_dev='' part_label='' full_label='' - local part_uuid='' full_uuid='' dev_remote='' full_fs='' line_max_label_uuid=$(( $LINE_MAX - 10 )) + local part_uuid='' full_uuid='' dev_remote='' full_fs='' line_max_label_uuid=$COLS_INNER local b_non_dev='false' holder='' # set A_PARTITION_DATA @@ -10436,7 +10620,7 @@ print_partition_data() else partitionIdClean=${a_partition_working[0]} fi - id_size_fs="${C1}ID:${C2} $partitionIdClean ${C1}size$SEP3${C2} ${a_partition_working[1]} $partition_used$full_fs$full_dev" + id_size_fs="${C1}ID$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 if [[ $B_SHOW_UUIDS == 'true' && $B_SHOW_LABELS == 'true' && $( calculate_line_length "$id_size_fs$label_uuid" ) -gt $line_max_label_uuid ]];then @@ -10460,13 +10644,13 @@ print_partition_data() else line_starter=' ' fi - partition_data=$( create_print_line "$line_starter" "${a_partition_data[$i]}" ) + partition_data=$( create_print_line "$line_starter" "${a_partition_data[$i]}${CN}" ) print_screen_output "$partition_data" done eval $LOGFE } - +# legacy not used print_program_version() { local patch_version_number=$( get_patch_version_string ) @@ -10475,9 +10659,9 @@ print_program_version() # left pad: sed -e :a -e 's/^.\{1,80\}$/& /;ta' # right pad: sed -e :a -e 's/^.\{1,80\}$/ &/;ta' # center pad: sed -e :a -e 's/^.\{1,80\}$/ & /;ta' - #local line_max=$(( $LINE_MAX - 10 )) + #local line_max=$COLS_INNER #program_version="$( sed -e :a -e "s/^.\{1,$line_max\}$/ &/;ta" <<< $program_version )" # use to create padding if needed - # program_version=$( create_print_line "Version:" "$program_version" ) + # program_version=$( create_print_line "Version:" "$program_version${CN}" ) print_screen_output "$program_version" } @@ -10527,7 +10711,7 @@ print_ps_item() fi # appName, appPath, appStarterName, appStarterPath, cpu, mem, pid, vsz, user - ps_data=$( create_print_line "$line_starter" "$line_start_data" ) + ps_data=$( create_print_line "$line_starter" "$line_start_data${CN}" ) print_screen_output "$ps_data" for (( i=0; i < ${#A_PS_DATA[@]}; i++ )) @@ -10548,7 +10732,7 @@ print_ps_item() app_name="$app_name ${C1}(started by$SEP3${C2} ${a_ps_data[2]}${C1})${C2}" fi app_pid=" ${C1}pid$SEP3${C2} ${a_ps_data[6]}" - # ${C1}user:${C2} ${a_ps_data[8]} + # ${C1}user$SEP3${C2} ${a_ps_data[8]} case $1 in cpu) app_cpu=" ${C1}cpu$SEP3${C2} ${a_ps_data[4]}%" @@ -10564,9 +10748,9 @@ print_ps_item() ;; esac (( line_counter++ )) - count_nu="${C1}$line_counter:${C2}" + count_nu="${C1}$line_counter$SEP3${C2}" full_line="$count_nu$app_cpu$app_mem$app_name$app_pid$extra_data" - ps_data=$( create_print_line " " "$full_line" ) + ps_data=$( create_print_line " " "$full_line${CN}" ) print_screen_output "$ps_data" done @@ -10643,7 +10827,7 @@ print_raid_data() if [[ ${a_raid_working[1]} == 'inactive' ]];then inactive=" - ${a_raid_working[1]}" fi - basic_raid="$basic_raid$basic_raid_separator${C1}$basic_counter${SEP3}${C2} $dev_string${a_raid_working[0]}$inactive" + basic_raid="$basic_raid$basic_raid_separator${C1}$basic_counter$SEP3${C2} $dev_string${a_raid_working[0]}$inactive" basic_raid_separator=' ' (( basic_counter++ )) else @@ -10664,7 +10848,7 @@ print_raid_data() if [[ ${a_raid_working[2]} == '' && ${a_raid_working[1]} == 'inactive' ]];then raid_level='' else - raid_level=" ${C1}raid${SEP3}${C2} $raid_level" + raid_level=" ${C1}raid$SEP3${C2} $raid_level" fi if [[ ${a_raid_working[4]} != '' ]];then device_report="${a_raid_working[4]}" @@ -10677,17 +10861,17 @@ print_raid_data() else blocks='N/A' fi - blocks=" ${C1}$blocks_avail${SEP3}${C2} $blocks" + blocks=" ${C1}$blocks_avail$SEP3${C2} $blocks" if [[ ${a_raid_working[9]} != '' ]];then chunk_size=${a_raid_working[9]} else chunk_size='N/A' fi - chunk_size=" ${C1}$chunk_raid_usage${SEP3}${C2} $chunk_size" + chunk_size=" ${C1}$chunk_raid_usage$SEP3${C2} $chunk_size" if [[ ${a_raid_working[10]} != '' ]];then bitmap_value='true' - bitmap_value=" ${C1}bitmap${SEP3}${C2} $bitmap_value" + bitmap_value=" ${C1}bitmap$SEP3${C2} $bitmap_value" fi fi if [[ $B_EXTRA_EXTRA_DATA == 'true' ]];then @@ -10695,10 +10879,10 @@ print_raid_data() u_data=" ${a_raid_working[5]}" fi if [[ ${a_raid_working[7]} != '' ]];then - super_blocks=" ${C1}super blocks${SEP3}${C2} ${a_raid_working[7]}" + super_blocks=" ${C1}super blocks$SEP3${C2} ${a_raid_working[7]}" fi if [[ ${a_raid_working[8]} != '' ]];then - algorithm=" ${C1}algorithm${SEP3}${C2} ${a_raid_working[8]}" + algorithm=" ${C1}algorithm$SEP3${C2} ${a_raid_working[8]}" fi fi if [[ ${a_raid_working[3]} == '' ]];then @@ -10727,10 +10911,10 @@ print_raid_data() done if [[ $failed != '' ]];then - failed=" ${C1}FAILED${SEP3}${C2}$failed${C2}" + failed=" ${C1}FAILED$SEP3${C2}$failed${C2}" fi if [[ $spare != '' ]];then - spare=" ${C1}spare${SEP3}${C2}$spare${C2}" + spare=" ${C1}spare$SEP3${C2}$spare${C2}" fi if [[ -n $device_components || -n $spare || -n $failed ]];then @@ -10742,20 +10926,20 @@ print_raid_data() if [[ $device_components == '' ]];then device_components='none' fi - device_components="${C1}online${SEP3}${C2} $device_components" - device_components=" ${C1}components${SEP3}${C2} $device_components$failed$spare" + device_components="${C1}online$SEP3${C2} $device_components" + device_components=" ${C1}components$SEP3${C2} $device_components$failed$spare" fi fi - a_raid_data[$raid_counter]="${C1}Device$device_id${SEP3}${C2} $device$device_state$raid_level$device_components" + a_raid_data[$raid_counter]="${C1}Device$device_id$SEP3${C2} $device$device_state$raid_level$device_components" if [[ $B_EXTRA_DATA == 'true' && ${a_raid_working[1]} != 'inactive' ]];then - a_raid_data[$raid_counter]="${C1}Device$device_id${SEP3}${C2} $device$device_state$device_components" + a_raid_data[$raid_counter]="${C1}Device$device_id$SEP3${C2} $device$device_state$device_components" (( raid_counter++ )) - print_string="${C1}Info${SEP3}${C2}$raid_level ${C1}$report_size${SEP3}${C2} $device_report$u_data" + print_string="${C1}Info$SEP3${C2}$raid_level ${C1}$report_size$SEP3${C2} $device_report$u_data" print_string="$print_string$blocks$chunk_size$bitmap_value$super_blocks$algorithm" a_raid_data[$raid_counter]="$print_string" else - a_raid_data[$raid_counter]="${C1}Device$device_id${SEP3}${C2} $device$device_state$raid_level$device_components" + a_raid_data[$raid_counter]="${C1}Device$device_id$SEP3${C2} $device$device_state$raid_level$device_components" fi (( raid_counter++ )) @@ -10767,10 +10951,10 @@ print_raid_data() else finish_time='N/A' fi - finish_time=" ${C1}time remaining${SEP3}${C2} $finish_time" + finish_time=" ${C1}time remaining$SEP3${C2} $finish_time" if [[ $B_EXTRA_DATA == 'true' ]];then if [[ ${a_raid_working[13]} != '' ]];then - recovered_sectors=" ${C1}sectors${SEP3}${C2} ${a_raid_working[13]}" + recovered_sectors=" ${C1}sectors$SEP3${C2} ${a_raid_working[13]}" fi fi if [[ $B_EXTRA_EXTRA_DATA == 'true' ]];then @@ -10778,11 +10962,11 @@ print_raid_data() recovery_progress_bar=" ${a_raid_working[11]}" fi if [[ ${a_raid_working[15]} != '' ]];then - recovery_speed=" ${C1}speed${SEP3}${C2} ${a_raid_working[15]}" + recovery_speed=" ${C1}speed$SEP3${C2} ${a_raid_working[15]}" fi fi - a_raid_data[$raid_counter]="${C1}Recovering${SEP3}${C2} $recovery_percent$recovery_progress_bar$recovered_sectors$finish_time$recovery_speed" + a_raid_data[$raid_counter]="${C1}Recovering$SEP3${C2} $recovery_percent$recovery_progress_bar$recovered_sectors$finish_time$recovery_speed" (( raid_counter++ )) fi fi @@ -10792,11 +10976,11 @@ print_raid_data() else kernel_support=${a_raid_working[1]} fi - kernel_support=" ${C1}supported${SEP3}${C2} $kernel_support" + kernel_support=" ${C1}supported$SEP3${C2} $kernel_support" elif [[ ${a_raid_working[0]} == 'ReadAhead' ]];then if [[ ${a_raid_working[1]} != '' ]];then read_ahead=${a_raid_working[1]} - read_ahead=" ${C1}read ahead${SEP3}${C2} $read_ahead" + read_ahead=" ${C1}read ahead$SEP3${C2} $read_ahead" fi elif [[ ${a_raid_working[0]} == 'UnusedDevices' ]];then if [[ ${a_raid_working[1]} == '' ]];then @@ -10804,17 +10988,17 @@ print_raid_data() else unused_devices=${a_raid_working[1]} fi - unused_devices="${C1}Unused Devices${SEP3}${C2} $unused_devices" + unused_devices="${C1}Unused Devices$SEP3${C2} $unused_devices" elif [[ ${a_raid_working[0]} == 'raidEvent' ]];then if [[ ${a_raid_working[1]} != '' ]];then raid_event=${a_raid_working[1]} - raid_event=" ${C1}Raid Event${SEP3}${C2} ${a_raid_working[1]}" + raid_event=" ${C1}Raid Event$SEP3${C2} ${a_raid_working[1]}" fi fi done if [[ $B_SHOW_BASIC_RAID == 'true' && $basic_raid != '' ]];then - a_raid_data[0]="${C1}Device$basic_raid_plural${SEP3}${C2} $basic_raid" + a_raid_data[0]="${C1}Device$basic_raid_plural$SEP3${C2} $basic_raid" fi # note bsd temp test hack to make it run if [[ $B_MDSTAT_FILE != 'true' && -z $BSD_TYPE ]] || \ @@ -10835,7 +11019,7 @@ print_raid_data() # now let's add on the system line and the unused device line. Only print on -xx if [[ $kernel_support$read_ahead$raid_event != '' ]];then array_count=${#a_raid_data[@]} - a_raid_data[array_count]="${C1}System${SEP3}${C2}$kernel_support$read_ahead$raid_event" + a_raid_data[array_count]="${C1}System$SEP3${C2}$kernel_support$read_ahead$raid_event" loop_limit=1 fi if [[ $unused_devices != '' ]];then @@ -10857,7 +11041,7 @@ print_raid_data() fi if [[ $B_EXTRA_EXTRA_DATA == 'true' && $array_count != '' ]];then if [[ $i == 0 ]];then - raid_data=$( create_print_line "$line_starter" "${a_raid_data[array_count]}" ) + raid_data=$( create_print_line "$line_starter" "${a_raid_data[array_count]}${CN}" ) print_screen_output "$raid_data" line_starter=' ' fi @@ -10866,7 +11050,7 @@ print_raid_data() print_screen_output "$raid_data" if [[ $B_EXTRA_EXTRA_DATA == 'true' && $array_count_unused != '' ]];then if [[ $i == $(( array_count_unused - 2 )) ]];then - raid_data=$( create_print_line "$line_starter" "${a_raid_data[array_count_unused]}" ) + raid_data=$( create_print_line "$line_starter" "${a_raid_data[array_count_unused]}${CN}" ) print_screen_output "$raid_data" fi fi @@ -10896,7 +11080,7 @@ print_repo_data() # this will dump unwanted white space line starters. Some irc channels # use bots that show page title for urls, so need to break the url by adding # a white space. - if [[ $B_RUNNING_IN_SHELL != 'true' ]];then + if [[ $B_IRC == 'true' ]];then file_content=$( echo $file_content | sed 's|://|: //|' ) else file_content=$( echo $file_content ) @@ -10905,9 +11089,9 @@ print_repo_data() # check file name, if different, update the holder for print out if [[ $file_name != $file_name_holder ]];then if [[ $repo_type == 'pisi repo' || $repo_type == 'urpmq repo' ]];then - repo_full="${C1}$repo_type:${C2} $file_name" + repo_full="${C1}$repo_type$SEP3${C2} $file_name" else - repo_full="${C1}Active $repo_type in file:${C2} $file_name" + repo_full="${C1}Active $repo_type in file$SEP3${C2} $file_name" fi file_name_holder=$file_name b_print_next_line='true' @@ -10916,9 +11100,9 @@ print_repo_data() fi # first line print Repos: if [[ $repo_count -eq 1 ]];then - repo_full=$( create_print_line "Repos:" "$repo_full" ) + repo_full=$( create_print_line "Repos:" "$repo_full${CN}" ) else - repo_full=$( create_print_line " " "$repo_full" ) + repo_full=$( create_print_line " " "$repo_full${CN}" ) fi print_screen_output "$repo_full" # this prints the content of the file as well as the file name @@ -10929,7 +11113,7 @@ print_repo_data() fi done <<< "$REPO_DATA" else - repo_full=$( create_print_line "Repos:" "${C1}Error:${C2} $SCRIPT_NAME does not support this feature for your distro yet." ) + repo_full=$( create_print_line "Repos:" "${C1}Error$SEP3${C2} $SCRIPT_NAME does not support this feature for your distro yet." ) print_screen_output "$repo_full" fi eval $LOGFE @@ -10987,10 +11171,10 @@ print_sensors_data() gpu_temp=$( get_gpu_temp_data ) # dump the unneeded screen data for single gpu systems if [[ $( wc -w <<< $gpu_temp ) -eq 1 && $B_EXTRA_DATA != 'true' ]];then - gpu_temp=$( cut -d ':' -f 2 <<< $gpu_temp ) + gpu_temp=${gpu_temp#*:} fi if [[ -n $gpu_temp ]];then - gpu_temp="${C1}gpu$SEP3${C2} ${gpu_temp} " + gpu_temp="${C1}gpu$SEP3${C2} $gpu_temp " fi ;; # then the fan data from main fan array @@ -11063,16 +11247,16 @@ print_sensors_data() # unless -s used explicitly. So for -F type output won't show unless valid or -! 1 used if [[ $b_is_error != 'true' || $B_SHOW_SENSORS == 'true' || $B_TESTING_1 == 'true' ]];then temp_data="$cpu_temp$mobo_temp$psu_temp$gpu_temp" - temp_data=$( create_print_line "Sensors:" "$temp_data" ) + temp_data=$( create_print_line "Sensors:" "$temp_data${CN}" ) print_screen_output "$temp_data" # don't print second or subsequent lines if error data fan_data="$cpu_fan$mobo_fan$ps_fan$sys_fans" if [[ $b_is_error != 'true' && -n $fan_data ]];then - fan_data=$( create_print_line " " "$fan_data" ) + fan_data=$( create_print_line " " "$fan_data${CN}" ) print_screen_output "$fan_data" # and then second wrapped fan line if needed if [[ -n $sys_fans2 ]];then - fan_data2=$( create_print_line " " "$sys_fans2" ) + fan_data2=$( create_print_line " " "$sys_fans2${CN}" ) print_screen_output "$fan_data2" fi fi @@ -11084,7 +11268,8 @@ print_system_data() { eval $LOGFS local system_data='' bits='' desktop_environment='' dm_data='' de_extra_data='' - local host_kernel_string='' de_distro_string='' host_string='' desktop_type='Desktop' + local de_string='' distro_string='' line_starter='System:' + local host_kernel_string='' host_string='' desktop_type='Desktop' local host_name=$HOSTNAME local current_kernel=$( get_kernel_version ) local distro="$( get_distro_data )" @@ -11128,12 +11313,10 @@ print_system_data() dm_data=" ${C1}dm$SEP3${C2} $dm_data" fi fi - - de_distro_string="${C1}$desktop_type$SEP3${C2} $desktop_environment$de_extra_data$dm_data ${C1}Distro$SEP3${C2} $distro" if [[ $B_EXTRA_DATA == 'true' ]];then gcc_string=$( get_gcc_kernel_version ) if [[ -n $gcc_string ]];then - gcc_string=", ${C1}gcc$SEP3${C2} $gcc_string" + gcc_string=" ${C1}gcc$SEP3${C2} $gcc_string" fi fi # check for 64 bit first @@ -11142,7 +11325,7 @@ print_system_data() else bits="32" fi - bits=" (${bits} bit${gcc_string})" + bits=" ($bits bit$gcc_string)" if [[ $B_SHOW_HOST == 'true' ]];then if [[ -z $HOSTNAME ]];then if [[ -n $( type p hostname ) ]];then @@ -11153,18 +11336,31 @@ print_system_data() fi fi host_string="${C1}Host$SEP3${C2} $host_name " - system_data=$( create_print_line "System:" "$host_string$host_name ${C1}Kernel$SEP3${C2}" ) fi host_kernel_string="$host_string${C1}Kernel$SEP3${C2} $current_kernel$bits " - if [[ $( calculate_line_length "$host_kernel_string$de_distro_string" ) -lt $LINE_MAX ]];then - system_data="$host_kernel_string$de_distro_string" - system_data=$( create_print_line "System:" "$system_data" ) - else - system_data=$( create_print_line "System:" "$host_kernel_string" ) + de_string="${C1}$desktop_type$SEP3${C2} $desktop_environment$de_extra_data$dm_data " + distro_string="${C1}Distro$SEP3${C2} $distro " + + if [[ $( calculate_line_length "$host_kernel_string$de_string" ) -gt $COLS_INNER ]];then + system_data=$( create_print_line "$line_starter" "$host_kernel_string${CN}" ) print_screen_output "$system_data" - system_data=$( create_print_line " " "$de_distro_string" ) + host_kernel_string='' + line_starter=' ' fi - print_screen_output "$system_data" + if [[ $( calculate_line_length "$host_kernel_string$de_string$distro_string" ) -gt $COLS_INNER ]];then + system_data=$( create_print_line "$line_starter" "$host_kernel_string$de_string${CN}" ) + print_screen_output "$system_data" + host_kernel_string='' + de_string='' + line_starter=' ' + fi + system_data="$host_kernel_string$de_string$distro_string" + if [[ -n $system_data ]];then + system_data="$host_kernel_string$de_string$distro_string" + system_data=$( create_print_line "$line_starter" "$system_data${CN}" ) + print_screen_output "$system_data" + fi + eval $LOGFE } @@ -11191,7 +11387,7 @@ print_unmounted_partition_data() else full_dev="/dev/${a_unmounted_data[0]}" fi - full_dev="${C1}ID:${C2} $full_dev" + full_dev="${C1}ID$SEP3${C2} $full_dev" if [[ -z ${a_unmounted_data[1]} ]];then full_size='N/A' else @@ -11225,11 +11421,11 @@ print_unmounted_partition_data() if [[ $BSD_TYPE == 'bsd' ]];then full_string=$bsd_unsupported fi - unmounted_data=$( create_print_line "$line_starter" "$full_string" ) + unmounted_data=$( create_print_line "$line_starter" "$full_string${CN}" ) print_screen_output "$unmounted_data" done else - unmounted_data=$( create_print_line "Unmounted:" "No unmounted partitions detected" ) + unmounted_data=$( create_print_line "Unmounted:" "No unmounted partitions detected${CN}" ) print_screen_output "$unmounted_data" fi @@ -11246,7 +11442,7 @@ print_weather_data() local heat_index="" wind_chill='' dewpoint='' xxx_humidity='' local openP='(' closeP=')' - if [[ $B_RUNNING_IN_SHELL == 'false' ]];then + if [[ $B_IRC == 'true' ]];then openP='' closeP='' fi @@ -11303,11 +11499,11 @@ print_weather_data() if [[ $B_EXTRA_DATA != 'true' ]];then weather_data="$weather_string $time_string" - weather_data=$( create_print_line "Weather:" "$weather_data" ) + weather_data=$( create_print_line "Weather:" "$weather_data${CN}" ) print_screen_output "$weather_data" else weather_data="$weather_string" - weather_data=$( create_print_line "Weather:" "$weather_data" ) + weather_data=$( create_print_line "Weather:" "$weather_data${CN}" ) print_screen_output "$weather_data" if [[ $B_EXTRA_EXTRA_EXTRA_DATA == 'true' ]];then if [[ -n ${a_weather[8]} ]];then @@ -11343,10 +11539,10 @@ print_weather_data() fi # the last three are oftenblank if [[ -z "$heat_index$wind_chill$dew_point" ]];then - weather_data=$( create_print_line " " "$pressure$location_string" ) + weather_data=$( create_print_line " " "$pressure$location_string${CN}" ) print_screen_output "$weather_data" else - weather_data=$( create_print_line " " "$pressure$heat_index$wind_chill$dew_point" ) + weather_data=$( create_print_line " " "$pressure$heat_index$wind_chill$dew_point${CN}" ) print_screen_output "$weather_data" if [[ $B_OUTPUT_FILTER != 'true' ]];then weather_data=$( create_print_line " " "$location_string" ) @@ -11354,13 +11550,13 @@ print_weather_data() fi fi if [[ -n $time_string$observation_time ]];then - weather_data=$( create_print_line " " "$time_string$observation_time" ) + weather_data=$( create_print_line " " "$time_string$observation_time${CN}" ) print_screen_output "$weather_data" fi else if [[ -n $pressure$time_string ]];then weather_data="$pressure$time_string" - weather_data=$( create_print_line " " "$weather_data" ) + weather_data=$( create_print_line " " "$weather_data${CN}" ) print_screen_output "$weather_data" fi fi @@ -11368,7 +11564,7 @@ print_weather_data() else weather_data=$( create_print_line "Weather:" "Weather data failure: $(date)" ) print_screen_output "$weather_data" - weather_data=$( create_print_line " " "${A_WEATHER_DATA}" ) + weather_data=$( create_print_line " " "${A_WEATHER_DATA}${CN}" ) print_screen_output "$weather_data" fi eval $LOGFE