+get_runlevel_data()
+{
+ eval $LOGFS
+ local runlvl=''
+ local runlevel_path=$( type -p runlevel )
+ if [[ -n $runlevel_path ]];then
+ runlvl="$( $runlevel_path | gawk '{ print $2 }' )"
+ fi
+ echo $runlvl
+ eval $LOGFE
+}
+
+# note: it appears that at least as of 2014-01-13, /etc/inittab is going to be used for
+# default runlevel in upstart/sysvinit. systemd default is not always set so check to see
+# if it's linked.
+get_runlevel_default()
+{
+ eval $LOGFS
+ local default_runlvl=''
+ local inittab='/etc/inittab'
+ local systemd_default='/etc/systemd/system/default.target'
+ local upstart_default='/etc/init/rc-sysinit.conf'
+
+ # note: systemd systems do not necessarily have this link created
+ if [[ -L $systemd_default ]];then
+ default_runlvl=$( readlink $systemd_default )
+ if [[ -n $default_runlvl ]];then
+ default_runlvl=$( basename $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
+ # not matter, we just want to know the system default
+ elif [[ -e $upstart_default ]];then
+ # env DEFAULT_RUNLEVEL=2
+ default_runlvl=$( gawk -F '=' '/^env[[:space:]]+DEFAULT_RUNLEVEL/ {
+ print $2
+ }' $upstart_default )
+ fi
+
+ # handle weird cases where null but inittab exists
+ if [[ -z $default_runlvl && -f $inittab ]];then
+ default_runlvl=$( gawk -F ':' '
+ /^id.*initdefault/ {
+ print $2
+ }' $inittab )
+ fi
+ echo $default_runlvl
+ eval $LOGFE
+}
+
+get_sensors_data()
+{
+ eval $LOGFS
+
+
+ local temp_array=''
+
+ IFS=$'\n'
+ if [[ -n $Sensors_Data ]];then
+ # note: non-configured sensors gives error message, which we need to redirect to stdout
+ # also, -F ':' no space, since some cases have the data starting right after,like - :1287
+ A_SENSORS_DATA=( $(
+ gawk -F ':' -v userCpuNo="$SENSORS_CPU_NO" '
+ BEGIN {
+ IGNORECASE=1
+ core0Temp="" # only if all else fails...
+ cpuTemp=""
+ cpuTempReal=""
+ fanWorking=""
+ indexCountaFanMain=0
+ indexCountaFanDefault=0
+ i=""
+ j=""
+ moboTemp=""
+ moboTempReal=""
+ psuTemp=""
+ separator=""
+ sysFanString=""
+ temp1=""
+ temp2=""
+ tempFanType="" # set to 1 or 2
+ tempUnit=""
+ tempWorking=""
+ tempWorkingUnit=""
+ }
+ # new data arriving: gpu temp in sensors, have to skip that
+ /^('"$SENSORS_GPU_SEARCH"')-pci/ {
+ while ( getline && !/^$/ ) {
+ # do nothing, just skip it
+ }
+ }
+ # dumping the extra + signs after testing for them, nobody has negative temps.
+ # also, note gawk treats ° as a space, so we have to get the C/F data
+ # there are some guesses here, but with more sensors samples it will get closer.
+ # note: using arrays starting at 1 for all fan arrays to make it easier overall
+ # more validation because gensub if fails to get match returns full string, so
+ # we have to be sure we are working with the actual real string before assiging
+ # data to real variables and arrays. Extracting C/F degree unit as well to use
+ # when constructing temp items for array.
+ # note that because of charset issues, no tempUnit="°" tempWorkingUnit degree sign
+ # used, but it is required in testing regex to avoid error.
+ /^(M\/B|MB|SIO|SYS)(.*)\+([0-9]+)(.*)[ \t°](C|F)/ && $2 ~ /^[ \t]*\+([0-9]+)/ {
+ moboTemp=gensub( /[ \t]+\+([0-9\.]*)(.*)/, "\\1", 1, $2 )
+ tempWorkingUnit=gensub( /[ \t]+\+([0-9\.]+)[ \t°]+([CF])(.*)/, "\\2", 1, $2 )
+ if ( tempWorkingUnit ~ /^C|F$/ && tempUnit == "" ){
+ tempUnit=tempWorkingUnit
+ }
+ }
+ /^CPU(.*)\+([0-9]+)(.*)[ \t°](C|F)/ && $2 ~ /^[ \t]*\+([0-9]+)/ {
+ cpuTemp=gensub( /[ \t]+\+([0-9\.]+)(.*)/, "\\1", 1, $2 )
+ tempWorkingUnit=gensub( /[ \t]+\+([0-9\.]+)[ \t°]+([CF])(.*)/, "\\2", 1, $2 )
+ if ( tempWorkingUnit ~ /^C|F$/ && tempUnit == "" ){
+ tempUnit=tempWorkingUnit
+ }
+ }
+ /^(P\/S|Power)(.*)\+([0-9]+)(.*)[ \t°](C|F)/ && $2 ~ /^[ \t]*\+([0-9]+)/ {
+ psuTemp=gensub( /[ \t]+\+([0-9\.]+)(.*)/, "\\1", 1, $2 )
+ tempWorkingUnit=gensub( /[ \t]+\+([0-9\.]+)[ \t°]+([CF])(.*)/, "\\2", 1, $2 )
+ if ( tempWorkingUnit ~ /^C|F$/ && tempUnit == "" ){
+ tempUnit=tempWorkingUnit
+ }
+ }
+ $1 ~ /^temp1$/ && $2 ~ /^[ \t]*\+([0-9]+)/ {
+ tempWorking=gensub( /[ \t]+\+([0-9\.]+)(.*)/, "\\1", 1, $2 )
+ if ( temp1 == "" || tempWorking > 0 ) {
+ temp1=tempWorking
+ }
+ tempWorkingUnit=gensub( /[ \t]+\+([0-9\.]+)[ \t°]+([CF])(.*)/, "\\2", 1, $2 )
+ if ( tempWorkingUnit ~ /^C|F$/ && tempUnit == "" ){
+ tempUnit=tempWorkingUnit
+ }
+ }
+ $1 ~ /^temp2$/ && $2 ~ /^[ \t]*\+([0-9]+)/ {
+ tempWorking=gensub( /[ \t]+\+([0-9\.]+)(.*)/, "\\1", 1, $2 )
+ if ( temp2 == "" || tempWorking > 0 ) {
+ temp2=tempWorking
+ }
+ tempWorkingUnit=gensub( /[ \t]+\+([0-9\.]+)[ \t°]+([CF])(.*)/, "\\2", 1, $2 )
+ if ( tempWorkingUnit ~ /^C|F$/ && tempUnit == "" ){
+ tempUnit=tempWorkingUnit
+ }
+ }
+
+ # final fallback if all else fails, funtoo user showed sensors putting
+ # temp on wrapped second line, not handled
+ /^(core0|core 0)(.*)\+([0-9]+)(.*)[ \t°](C|F)/ && $2 ~ /^[ \t]*\+([0-9]+)/ {
+ tempWorking=gensub( /[ \t]+\+([0-9\.]+)(.*)/, "\\1", 1, $2 )
+ if ( core0Temp == "" || tempWorking > 0 ) {
+ core0Temp=tempWorking
+ }
+ tempWorkingUnit=gensub( /[ \t]+\+([0-9\.]+)[ \t°]+([CF])(.*)/, "\\2", 1, $2 )
+ if ( tempWorkingUnit ~ /^C|F$/ && tempUnit == "" ){
+ tempUnit=tempWorkingUnit
+ }
+ }
+
+ # note: can be cpu fan:, cpu fan speed:, etc. Some cases have no space before
+ # $2 starts (like so :1234 RPM), so skip that space test in regex
+ /^CPU(.*)[ \t]*([0-9]+)[ \t]RPM/ {
+ aFanMain[1]=gensub( /[ \t]*([0-9]+)[ \t]+(.*)/, "\\1", 1, $2 )
+ }
+ /^(M\/B|MB|SYS)(.*)[ \t]*([0-9]+)[ \t]RPM/ {
+ aFanMain[2]=gensub( /[ \t]*([0-9]+)[ \t]+(.*)/, "\\1", 1, $2 )
+ }
+ /(Power|P\/S|POWER)(.*)[ \t]*([0-9]+)[ \t]RPM/ {
+ aFanMain[3]=gensub( /[ \t]*([0-9]+)[ \t]+(.*)/, "\\1", 1, $2 )
+ }
+ # note that the counters are dynamically set for fan numbers here
+ # otherwise you could overwrite eg aux fan2 with case fan2 in theory
+ # note: cpu/mobo/ps are 1/2/3
+ # NOTE: test: ! i in array does NOT work, this appears to be an awk/gawk bug
+ /^(AUX(1)? |CASE(1)? |CHASSIS(1)? )(.*)[ \t]*([0-9]+)[ \t]RPM/ {
+ for ( i = 4; i < 7; i++ ){
+ if ( i in aFanMain ){
+ ##
+ }
+ else {
+ aFanMain[i]=gensub( /[ \t]*([0-9]+)[ \t]+(.*)/, "\\1", 1, $2 )
+ break
+ }
+ }
+ }
+ /^(AUX([2-9]) |CASE([2-9]) |CHASSIS([2-9]) )(.*)[ \t]*([0-9]+)[ \t]RPM/ {
+ for ( i = 5; i < 30; i++ ){
+ if ( i in aFanMain ) {
+ ##
+ }
+ else {
+ sysFanNu = i
+ aFanMain[i]=gensub( /[ \t]*([0-9]+)[ \t]+(.*)/, "\\1", 1, $2 )
+ break
+ }
+ }
+ }
+ # in rare cases syntax is like: fan1: xxx RPM
+ /^(FAN(1)?[ \t:])(.*)[ \t]*([0-9]+)[ \t]RPM/ {
+ aFanDefault[1]=gensub( /[ \t]*([0-9]+)[ \t]+(.*)/, "\\1", 1, $2 )
+ }
+ /^FAN([2-9]|1[0-9])(.*)[ \t]*([0-9]+)[ \t]RPM/ {
+ fanWorking=gensub( /[ \t]*([0-9]+)[ \t]+(.*)/, "\\1", 1, $2 )
+ sysFanNu=gensub( /fan([0-9]+)/, "\\1", 1, $1 )
+ if ( sysFanNu ~ /^([0-9]+)$/ ) {
+ # add to array if array index does not exist OR if number is > existing number
+ if ( sysFanNu in aFanDefault ) {
+ if ( fanWorking >= aFanDefault[sysFanNu] ) {
+ aFanDefault[sysFanNu]=fanWorking
+ }
+ }
+ else {
+ aFanDefault[sysFanNu]=fanWorking
+ }
+ }
+ }
+
+ END {
+ # first we need to handle the case where we have to determine which temp/fan to use for cpu and mobo:
+ # note, for rare cases of weird cool cpus, user can override in their prefs and force the assignment
+ if ( temp1 != "" && temp2 != "" ){
+ if ( userCpuNo != "" && userCpuNo ~ /(1|2)/ ) {
+ tempFanType=userCpuNo
+ }
+ else {
+ # first some fringe cases with cooler cpu than mobo: assume which is cpu temp based on fan speed
+ # but only if other fan speed is 0
+ if ( temp1 >= temp2 && 1 in aFanDefault && 2 in aFanDefault && aFanDefault[1] == 0 && aFanDefault[2] > 0 ) {
+ tempFanType=2
+ }
+ else if ( temp2 >= temp1 && 1 in aFanDefault && 2 in aFanDefault && aFanDefault[2] == 0 && aFanDefault[1] > 0 ) {
+ tempFanType=1
+ }
+ # then handle the standard case if these fringe cases are false
+ else if ( temp1 >= temp2 ) {
+ tempFanType=1
+ }
+ else {
+ tempFanType=2
+ }
+ }
+ }
+ # need a case for no temps at all reported, like with old intels
+ else if ( temp2 == "" && cpuTemp == "" ){
+ if ( temp1 == "" && moboTemp == "" ){
+ tempFanType=1
+ }
+ else if ( temp1 != "" && moboTemp == "" ){
+ tempFanType=1
+ }
+ else if ( temp1 != "" && moboTemp != "" ){
+ tempFanType=1
+ }
+ }
+
+ # then get the real cpu temp, best guess is hottest is real
+ if ( cpuTemp != "" ){
+ cpuTempReal=cpuTemp
+ }
+ else if ( tempFanType != "" ){
+ if ( tempFanType == 1 ){
+ cpuTempReal=temp1
+ }
+ else {
+ cpuTempReal=temp2
+ }
+ }
+ else {
+ cpuTempReal=temp1
+ }
+ # if all else fails, use core0 temp if it is present and cpu is null
+ if ( cpuTempReal == "" && core0Temp != "" ) {
+ cpuTempReal=core0Temp
+ }
+
+ # then the real mobo temp
+ if ( moboTemp != "" ){
+ moboTempReal=moboTemp
+ }
+ else if ( tempFanType != "" ){
+ if ( tempFanType == 1 ) {
+ moboTempReal=temp2
+ }
+ else {
+ moboTempReal=temp1
+ }
+ }
+ else {
+ moboTempReal=temp2
+ }
+ # then set the cpu fan speed
+ if ( aFanMain[1] == "" ) {
+ # note, you cannot test for aFanDefault[1] or [2] != ""
+ # because that creates an array item in gawk just by the test itself
+ if ( tempFanType == 1 && 1 in aFanDefault ) {
+ aFanMain[1]=aFanDefault[1]
+ aFanDefault[1]=""
+ }
+ else if ( tempFanType == 2 && 2 in aFanDefault ) {
+ aFanMain[1]=aFanDefault[2]
+ aFanDefault[2]=""
+ }
+ }
+
+ # then we need to get the actual numeric max array count for both fan arrays
+ for (i = 0; i <= 29; i++) {
+ if ( i in aFanMain && i > indexCountaFanMain ) {
+ indexCountaFanMain=i
+ }
+ }
+ for (i = 0; i <= 14; i++) {
+ if ( i in aFanDefault && i > indexCountaFanDefault ) {
+ indexCountaFanDefault=i
+ }
+ }
+
+ # clear out any duplicates. Primary fan real trumps fan working always if same speed
+ for (i = 1; i <= indexCountaFanMain; i++) {
+ if ( i in aFanMain && aFanMain[i] != "" && aFanMain[i] != 0 ) {
+ for (j = 1; j <= indexCountaFanDefault; j++) {
+ if ( j in aFanDefault && aFanMain[i] == aFanDefault[j] ) {
+ aFanDefault[j] = ""
+ }
+ }
+ }
+ }
+
+ # now see if you can find the fast little mobo fan, > 5000 rpm and put it as mobo
+ # note that gawk is returning true for some test cases when aFanDefault[j] < 5000
+ # which has to be a gawk bug, unless there is something really weird with arrays
+ # note: 500 > aFanDefault[j] < 1000 is the exact trigger, and if you manually
+ # assign that value below, the > 5000 test works again, and a print of the value
+ # shows the proper value, so the corruption might be internal in awk.
+ # Note: gensub is the culprit I think, assigning type string for range 501-1000 but
+ # type integer for all others, this triggers true for >
+ for (j = 1; j <= indexCountaFanDefault; j++) {
+ if ( j in aFanDefault && int( aFanDefault[j] ) > 5000 && aFanMain[2] == "" ) {
+ aFanMain[2] = aFanDefault[j]
+ aFanDefault[j] = ""
+ # then add one if required for output
+ if ( indexCountaFanMain < 2 ) {
+ indexCountaFanMain = 2
+ }
+ }
+ }
+
+ # then construct the sys_fan string for echo, note that iteration 1
+ # makes: fanDefaultString separator null, ie, no space or ,
+ for (j = 1; j <= indexCountaFanDefault; j++) {
+ fanDefaultString = fanDefaultString separator aFanDefault[j]
+ separator=","
+ }
+ separator="" # reset to null for next loop
+ # then construct the sys_fan string for echo
+ for (j = 1; j <= indexCountaFanMain; j++) {
+ fanMainString = fanMainString separator aFanMain[j]
+ separator=","
+ }
+
+ # and then build the temps:
+ if ( moboTempReal != "" ) {
+ moboTempReal = moboTempReal tempUnit
+ }
+ if ( cpuTempReal != "" ) {
+ cpuTempReal = cpuTempReal tempUnit
+ }
+
+ # if they are ALL null, print error message. psFan is not used in output currently
+ if ( cpuTempReal == "" && moboTempReal == "" && aFanMain[1] == "" && aFanMain[2] == "" && aFanMain[3] == "" && fanDefaultString == "" ) {
+ print "No active sensors found. Have you configured your sensors yet?"
+ }
+ else {
+ # then build array arrays:
+ print cpuTempReal "," moboTempReal "," psuTemp
+ # this is for output, a null print line does NOT create a new array index in bash
+ if ( fanMainString == "" ) {
+ fanMainString=","
+ }
+ print fanMainString
+ print fanDefaultString
+ }
+ }' <<< "$Sensors_Data" ) )
+ fi
+
+ IFS="$ORIGINAL_IFS"
+ temp_array=${A_SENSORS_DATA[@]}
+ log_function_data "A_SENSORS_DATA: $temp_array"
+# echo "A_SENSORS_DATA: ${A_SENSORS_DATA[@]}"
+ eval $LOGFE
+}
+
+get_sensors_output()
+{
+ local sensors_path=$( type -p sensors ) sensors_data=''
+
+ if [[ -n $sensors_path ]];then
+ sensors_data="$( $sensors_path 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
+ sensors_data="$sensors_data\n\n###"
+ fi
+ fi
+ echo -e "$sensors_data"
+}
+
+get_shell_data()
+{
+ eval $LOGFS
+
+ local shell_type="$( ps -p $PPID -o comm= 2>/dev/null )"
+ local shell_version=''
+
+ if [[ $B_EXTRA_DATA == 'true' && -n $shell_type ]];then
+ case $shell_type in
+ bash)
+ shell_version=$( get_de_app_version "$shell_type" "^GNU[[:space:]]bash,[[:space:]]version" "4" | \
+ sed $SED_RX 's/(\(.*|-release|-version)//' )
+ ;;
+ # csh/dash use dpkg package version data, debian/buntu only
+ csh)
+ shell_version=$( get_de_app_version "$shell_type" "^tcsh" "2" )
+ ;;
+ dash)
+ shell_version=$( get_de_app_version "$shell_type" "$shell_type" "3" )
+ ;;
+ ksh)
+ shell_version=$( get_de_app_version "$shell_type" "version" "5" )
+ ;;
+ tcsh)
+ shell_version=$( get_de_app_version "$shell_type" "^tcsh" "2" )
+ ;;
+ zsh)
+ shell_version=$( get_de_app_version "$shell_type" "^zsh" "2" )
+ ;;
+ esac
+ fi
+ if [[ -n $shell_version ]];then
+ shell_type="$shell_type $shell_version"
+ fi
+ echo $shell_type
+
+ eval $LOGFS
+}
+
+get_shell_parent()
+{
+ eval $LOGFS
+ local shell_parent='' script_parent=''
+
+ # removed --no-headers to make bsd safe, adding in -j to make output the same
+ script_parent=$( ps -j -fp $PPID 2>/dev/null | gawk '/'"$PPID"'/ { print $3 }' )
+ log_function_data "script parent: $script_parent"
+ shell_parent=$( ps -j -p $script_parent 2>/dev/null | gawk '/'"$script_parent"'/ { print $NF}' )
+ # no idea why have to do script_parent action twice in su case, but you do, oh well.
+ if [[ $shell_parent == 'su' ]];then
+ script_parent=$( ps -j -fp $script_parent 2>/dev/null | gawk '/'"$script_parent"'/ { print $3 }' )
+ script_parent=$( ps -j -fp $script_parent 2>/dev/null | gawk '/'"$script_parent"'/ { print $3 }' )
+ shell_parent=$( ps -j -p $script_parent 2>/dev/null | gawk '/'"$script_parent"'/ { print $NF}' )
+ fi
+ echo $shell_parent
+ log_function_data "shell parent final: $shell_parent"
+ eval $LOGFE
+}
+
+# this will be used for some bsd data types
+# args: $1 - option type
+get_sysctl_data()
+{
+ eval $LOGFS
+
+ local sysctl_data=''
+
+ if [[ $B_SYSCTL ]];then
+ sysctl_data="$( sysctl -$1 )"
+ fi
+ # log_function_data "sysctl_data: $sysctl_data"
+ echo "$sysctl_data"
+ eval $LOGFE
+}
+
+get_tty_console_irc()
+{
+ eval $LOGFS
+ local tty_number=''
+ 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}'/ {
+ gsub(/[^0-9]/, "", $7)
+ print $7
+ exit
+ }' <<< "$Ps_aux_Data" )
+ fi
+ log_function_data "tty_number: $tty_number"
+ echo $tty_number
+ eval $LOGFE
+}
+
+get_tty_number()
+{
+ eval $LOGFS
+
+ local tty_number=$( basename "$( tty 2>/dev/null )" | sed 's/[^0-9]*//g' )
+
+ echo $tty_number
+
+ eval $LOGFE
+}
+
+get_unmounted_partition_data()
+{
+ eval $LOGFS
+ local a_unmounted_working='' mounted_partitions='' separator='|' unmounted_fs=''
+ local dev_working='' uuid_working='' label_working='' a_raid_working='' raid_partitions=''
+
+ if [[ $B_PARTITIONS_FILE == 'true' ]];then
+ # set dev disk label/uuid data globals
+ get_partition_dev_data 'label'
+ get_partition_dev_data 'uuid'
+ # load the raid data array here so we can exclude its partitions
+ if [[ $B_RAID_SET != 'true' ]];then
+ get_raid_data
+ fi
+ # sr0 type cd drives are showing up now as unmounted partitions
+ mounted_partitions="scd[0-9]+|sr[0-9]+|cdrom[0-9]*|cdrw[0-9]*|dvd[0-9]*|dvdrw[0-9]*"
+ # create list for slicing out the mounted partitions
+ for (( i=0; i < ${#A_PARTITION_DATA[@]}; i++ ))
+ do
+ IFS=","
+ a_unmounted_working=( ${A_PARTITION_DATA[i]} )
+ IFS="$ORIGINAL_IFS"
+ if [[ -n ${a_unmounted_working[6]} ]];then
+ mounted_partitions="$mounted_partitions$separator${a_unmounted_working[6]}"
+ fi
+ done
+ # now we need to exclude the mdraid partitions from the unmounted partition output as well
+ for (( i=0; i < ${#A_RAID_DATA[@]}; i++ ))
+ do
+ IFS=","
+ a_raid_working=( ${A_RAID_DATA[i]} )
+ IFS="$ORIGINAL_IFS"
+ if [[ -n ${a_raid_working[3]} ]];then
+ raid_partitions=$( sed $SED_RX 's/(\([^\)]*\)|\[[^\]]*\])//g' <<< ${a_raid_working[3]}\
+ | sed 's/[[:space:]]\+/|/g' )
+ mounted_partitions="$mounted_partitions$separator$raid_partitions"
+ fi
+ done
+
+ A_UNMOUNTED_PARTITION_DATA=( $( grep -Ev '[[:space:]]('$mounted_partitions')$' $FILE_PARTITIONS | gawk '
+ BEGIN {
+ IGNORECASE=1
+ }
+ # note that size 1 means it is a logical extended partition container
+ # lvm might have dm-1 type syntax
+ # need to exclude loop type file systems, squashfs for example
+ /[a-z][0-9]+$|dm-[0-9]+$/ && $3 != 1 && $NF !~ /loop/ {
+ size = sprintf( "%.2f", $3*1024/1000**3 )
+ print $4 "," size "G"
+ }' ) )
+
+ for (( i=0; i < ${#A_UNMOUNTED_PARTITION_DATA[@]}; i++ ))
+ do
+ IFS=","
+ a_unmounted_working=( ${A_UNMOUNTED_PARTITION_DATA[i]} )
+ IFS="$ORIGINAL_IFS"
+
+ label_working=$( grep -E "${a_unmounted_working[0]}$" <<< "$DEV_DISK_LABEL" | gawk '{
+ print $(NF - 2)
+ }' )
+ uuid_working=$( grep -E "${a_unmounted_working[0]}$" <<< "$DEV_DISK_UUID" | gawk '{
+ print $(NF - 2)
+ }' )
+ unmounted_fs=$( get_unmounted_partition_filesystem "/dev/${a_unmounted_working[0]}" )
+
+ IFS=","
+ A_UNMOUNTED_PARTITION_DATA[i]=${a_unmounted_working[0]}","${a_unmounted_working[1]}","$label_working","$uuid_working","$unmounted_fs
+ IFS="$ORIGINAL_IFS"
+ done
+ fi
+# echo "${A_PARTITION_DATA[@]}"
+# echo "${A_UNMOUNTED_PARTITION_DATA[@]}"
+ eval $LOGFE
+}
+
+# a few notes, normally file -s requires root, but you can set user rights in /etc/sudoers.
+# list of file systems: http://en.wikipedia.org/wiki/List_of_file_systems
+# args: $1 - /dev/<disk><part> to be tested for
+get_unmounted_partition_filesystem()
+{
+ eval $LOGFS
+ local partition_filesystem='' sudo_command=''
+
+ if [[ $B_FILE_TESTED != 'true' ]];then
+ B_FILE_TESTED='true'
+ FILE_PATH=$( type -p file )
+ fi
+
+ if [[ $B_SUDO_TESTED != 'true' ]];then
+ B_SUDO_TESTED='true'
+ SUDO_PATH=$( type -p sudo )
+ fi
+
+ if [[ -n $FILE_PATH && -n $1 ]];then
+ # only use sudo if not root, -n option requires sudo -V 1.7 or greater. sudo will just error out
+ # which is the safest course here for now, otherwise that interactive sudo password thing is too annoying
+ # important: -n makes it non interactive, no prompt for password
+ if [[ $B_ROOT != 'true' && -n $SUDO_PATH ]];then
+ sudo_command='sudo -n '
+ fi
+ # this will fail if regular user and no sudo present, but that's fine, it will just return null
+ # note the hack that simply slices out the first line if > 1 items found in string
+ # also, if grub/lilo is on partition boot sector, no file system data is available
+ # BSD fix: -Eio -Em 1
+ partition_filesystem=$( eval $sudo_command $FILE_PATH -s $1 | grep -Eio '(ext2|ext3|ext4|ext5|ext[[:space:]]|ntfs|fat32|fat16|fat[[:space:]]\(.*\)|vfat|fatx|tfat|swap|btrfs|ffs[[:space:]]|hfs\+|hfs[[:space:]]plus|hfs[[:space:]]extended[[:space:]]version[[:space:]][1-9]|hfsj|hfs[[:space:]]|jfs[[:space:]]|nss[[:space:]]|reiserfs|reiser4|ufs2|ufs[[:space:]]|xfs[[:space:]]|zfs[[:space:]])' | grep -Em 1 '.*' )
+ if [[ -n $partition_filesystem ]];then
+ echo $partition_filesystem
+ fi
+ fi
+ eval $LOGFE
+}
+
+## return uptime string
+get_uptime()
+{
+ eval $LOGFS
+ ## note: removing gsub(/ /,"",a); to get get space back in there, goes right before print a
+ local uptime_value="$( uptime | gawk '{
+ a = gensub(/^.*up *([^,]*).*$/,"\\1","g",$0)
+ print a
+ }' )"
+ echo "$uptime_value"
+ log_function_data "uptime_value: $uptime_value"
+ eval $LOGFE
+}
+
+get_weather_data()
+{
+ eval $LOGFS
+
+ local location_site='http://geoip.ubuntu.com/lookup'
+ local weather_feed='http://api.wunderground.com/auto/wui/geo/WXCurrentObXML/index.xml?query='
+ local weather_spider='http://wunderground.com/'
+ local data_grab_error='' wget_error=0
+ local b_test_loc=false b_test_weather=false b_debug=false
+ 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=''
+
+ # first we get the location data, once that is parsed and handled, we move to getting the
+ # actual weather data, assuming no errors
+ if [[ -n $ALTERNATE_WEATHER_LOCATION ]];then
+ # note, this api does not support spaces in names, replace spaces with + sign.
+ location=$ALTERNATE_WEATHER_LOCATION
+ # echo $ALTERNATE_WEATHER_LOCATION;exit
+ else
+ if [[ $b_test_loc != 'true' ]];then
+ location_data=$( wget -q -t 1 -T $WGET_TIMEOUT -O- $location_site || wget_error=$? )
+ log_function_data "$location_data"
+ if [[ $wget_error -ne 0 ]];then
+ data_grab_error="Error: location server up but download error - wget: $wget_error"
+ fi
+ wget_error=0
+ else
+ if [[ -f $test_dir$test_location ]];then
+ location_data="$( cat $test_dir$test_location )"
+ else
+ data_grab_error="Error: location xml local file not found."
+ fi
+ fi
+ if [[ -n $data_grab_error ]];then
+ :
+ elif [[ -z $( grep -i '<Response' <<< $location_data ) ]];then
+ data_grab_error="Error: location downloaded but data contains no xml."
+ else
+ # clean up xml and make easy to process with newlines, note, bsd sed has no support for inserting
+ # \n dircctly so we have to use this hack
+ # location_data="$( sed $SED_RX 's|><|>\n<|g' <<< $location_data )"
+ location_data="$( sed $SED_RX 's|><|>\
+<|g' <<< $location_data )"
+ # echo -e "ld:\n$location_data"
+ location_array_value=$( gawk '
+ function clean(data) {
+ returnData=""
+ # some lines might be empty, so ignore those
+ if (data !~ /^<[^>]+>$/ ) {
+ returnData=gensub(/(.*>)([^<]*)(<.*)/, "\\2", 1, data)
+ }
+ return returnData
+ }
+ BEGIN {
+ IGNORECASE=1
+ locationString=""
+ countryCode=""
+ countryCode3=""
+ countryName=""
+ regionCode=""
+ regionName=""
+ city=""
+ postalCode=""
+ latitude=""
+ longitude=""
+ timeZone=""
+ areaCode=""
+ }
+ /CountryCode/ {
+ if ( $0 ~ /CountryCode3/ ){
+ countryCode3=clean($0)
+ }
+ else {
+ countryCode=clean($0)
+ }
+ }
+ /CountryName/ {
+ countryName = clean($0)
+ }
+ /RegionCode/ {
+ regionCode = clean($0)
+ }
+ /RegionName/ {
+ regionName = clean($0)
+ }
+ /City/ {
+ city = clean($0)
+ }
+ /ZipPostalCode/ {
+ postalCode = clean($0)
+ }
+ /Latitude/ {
+ latitude = clean($0)
+ }
+ /Longitude/ {
+ longitude = clean($0)
+ }
+ /TimeZone/ {
+ timeZone = clean($0)
+ }
+ END {
+ locationString = city ";" regionCode ";" regionName ";" countryName ";" countryCode ";" countryCode3
+ locationString = locationString ";" latitude "," longitude ";" postalCode ";" timeZone
+ print locationString
+ }' <<< "$location_data" )
+ fi
+ A_WEATHER_DATA[0]=$location_array_value
+ IFS=";"
+ a_location=( ${A_WEATHER_DATA[0]} )
+ IFS="$ORIGINAL_IFS"
+
+ # assign location, cascade from most accurate
+ # latitude,longitude first
+ if [[ -n ${a_location[6]} ]];then
+ location="${a_location[6]}"
+ # city,state next
+ elif [[ -n ${a_location[0]} && -n ${a_location[1]} ]];then
+ location="${a_location[0]},${a_location[1]}"
+ # postal code last, that can be a very large region
+ elif [[ -n ${a_location[7]} ]];then
+ location=${a_location[7]}
+ fi
+ fi
+ if [[ $b_debug == 'true' ]];then
+ echo -e "location array:\n${A_WEATHER_DATA[0]}"
+ echo "location: $location"
+ fi
+ log_function_data "location: $location"
+
+ if [[ -z $location && -z $data_grab_error ]];then
+ data_grab_error="Error: location data downloaded but no location detected."
+ fi
+
+ # now either dump process or go on to get weather data
+ if [[ -z $data_grab_error ]];then
+ if [[ $b_test_weather != 'true' ]];then
+ weather_data="$( wget -q -t 1 -T $WGET_TIMEOUT -O- $weather_feed"$location" || wget_error=$? )"
+ if [[ $wget_error -ne 0 ]];then
+ data_grab_error="Error: weather server up but download error - wget: $wget_error"
+ fi
+ log_function_data "$weather_data"
+ else
+ if [[ -f $test_dir$test_weather ]];then
+ weather_data="$( cat $test_dir$test_weather)"
+ else
+ data_grab_error="Error: weather feed xml local file not found."
+ fi
+ fi
+ if [[ -z $data_grab_error && -z $( grep -i '<current_observation' <<< $weather_data ) ]];then
+ data_grab_error="Error: weather data downloaded but shows no xml start."
+ fi
+ if [[ -z $data_grab_error ]];then
+ # trim off zeros
+ weather_data=$( sed 's/^[[:space:]]*//' <<< "$weather_data" )
+ site_elevation=$( grep -im 1 '<elevation>' <<< "$weather_data" | sed $SED_RX -e 's/<[^>]*>//g' \
+ -e 's/\.[0-9]*//' )
+ # we need to grab the location data from the feed for remote checks
+ if [[ -n $ALTERNATE_WEATHER_LOCATION && -n $weather_data ]];then
+ location_data=$( sed -e '/<current_observation>/,/<display_location>/d' -e '/<\/display_location>/,/<\/current_observation>/d' <<< "$weather_data" )
+ # echo -e "ld1:\n$location_data"
+ A_WEATHER_DATA[0]=$( gawk '
+ function clean(data) {
+ returnData=""
+ # some lines might be empty, so ignore those
+ if (data !~ /^<[^>]+>$/ ) {
+ returnData=gensub(/(.*>)([^<]*)(<.*)/, "\\2", 1, data)
+ gsub(/^[[:space:]]+|[[:space:]]+$|^NA$|^N\/A$/, "", returnData)
+ }
+ return returnData
+ }
+ BEGIN {
+ IGNORECASE=1
+ city=""
+ state=""
+ country=""
+ }
+ /<city>/ {
+ city=clean($0)
+ }
+ /<state>/ {
+ state=clean($0)
+ }
+ /<country>/ {
+ country=clean($0)
+ }
+ END {
+ print city ";" state ";;;;" country
+ }' <<< "$location_data" )
+ # echo -e "location:\n${A_WEATHER_DATA[0]}"
+ fi
+
+ # clean off everything before/after observation_location
+ weather_data=$( sed -e '/<current_observation>/,/<observation_location>/d' \
+ -e '/<icons>/,/<\/current_observation>/d' <<< "$weather_data" -e 's/^[[:space:]]*$//g' -e '/^$/d' )
+
+ # echo "$weather_data";exit
+ weather_array_value=$( gawk -v siteElevation="$site_elevation" '
+ function clean(data) {
+ returnData=""
+ # some lines might be empty, so ignore those
+ if (data !~ /^<[^>]+>$/ ) {
+ returnData=gensub(/(.*>)([^<]*)(<.*)/, "\\2", 1, data)
+ gsub(/^[[:space:]]+|[[:space:]]+$|^NA$|^N\/A$/, "", returnData)
+ }
+ return returnData
+ }
+ BEGIN {
+ IGNORECASE=1
+ observationTime=""
+ localTime=""
+ weather=""
+ tempString=""
+ humidity=""
+ windString=""
+ pressureString=""
+ dewpointString=""
+ heatIndexString=""
+ windChillString=""
+ weatherString=""
+ }
+ /observation_time>/ {
+ observationTime=clean($0)
+ sub(/Last Updated on /, "", observationTime )
+ }
+ /local_time>/ {
+ localTime=clean($0)
+ }
+ /<weather/ {
+ weather=clean($0)
+ }
+ /temperature_string/ {
+ tempString=clean($0)
+ }
+ /relative_humidity/ {
+ humidity=clean($0)
+ }
+ /wind_string/ {
+ windString=clean($0)
+ }
+ /pressure_string/ {
+ pressureString=clean($0)
+ }
+ /heat_index_string/ {
+ heatIndexString=clean($0)
+ }
+ /windchill_string/ {
+ windChillString=clean($0)
+ }
+ END {
+ weatherString = observationTime ";" localTime ";" weather ";" tempString ";" humidity
+ weatherString = weatherString ";" windString ";" pressureString ";" dewpointString ";" heatIndexString
+ weatherString = weatherString ";" windChillString ";" siteElevation
+ print weatherString
+ }' <<< "$weather_data" )
+ fi
+ if [[ -z $weather_array_value ]];then
+ data_grab_error="Error: weather info downloaded but no data detected."
+ else
+ A_WEATHER_DATA[1]=$weather_array_value
+ fi
+ fi
+ # now either dump process or go on to get weather data
+ if [[ -n $data_grab_error ]];then
+ A_WEATHER_DATA=$data_grab_error
+ log_function_data "data grab error: $data_grab_error"
+ fi
+
+ if [[ $b_debug == 'true' ]];then
+ echo "site_elevation: $site_elevation"
+ echo "${A_WEATHER_DATA[1]}"
+ fi
+ temp_array=${A_WEATHER_DATA[@]}
+ log_function_data "A_WEATHER_DATA: $temp_array"
+
+ eval $LOGFE
+}
+# ALTERNATE_WEATHER_LOCATION='portland,or'
+# get_weather_data;exit
+
+#### -------------------------------------------------------------------
+#### special data handling for specific options and conditions
+#### -------------------------------------------------------------------
+
+# args: $1 - string to strip color code characters out of
+# returns count of string length minus colors
+calculate_line_length()
+{
+ local string=$1
+ # ansi: \e[1;34m 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=${#string}
+ echo $count
+}
+
+## multiply the core count by the data to be calculated, bmips, cache
+# args: $1 - string to handle; $2 - cpu count
+calculate_multicore_data()
+{
+ eval $LOGFS
+ local string_number=$1 string_data=''
+
+ if [[ -n $( grep -Ei '( mb| kb)' <<< $1 ) ]];then
+ string_data=" $( gawk '{print $2}' <<< $1 )" # add a space for output
+ string_number=$( gawk '{print $1}' <<< $1 )
+ fi
+ # handle weird error cases where it's not a number
+ if [[ -n $( grep -E '^[0-9\.,]+$' <<< $string_number ) ]];then
+ string_number=$( echo $string_number $2 | gawk '{
+ total = $1*$2
+ print total
+ }' )
+ elif [[ $string_number == '' ]];then
+ string_number='N/A'
+ else
+ # I believe that the above returns 'unknown' by default so no need for extra text
+ string_number="$string_number "
+ fi
+ echo "$string_number$string_data"
+ log_function_data "string_numberstring_data: $string_number$string_data"
+ eval $LOGFE
+}
+
+# prints out shortened list of flags, the main ones of interest
+# args: $1 - string of cpu flags to process
+process_cpu_flags()
+{
+ eval $LOGFS
+
+ local cpu_flags_working=$1
+ local bits=$( uname -m | grep 64 )
+
+ # no need to show pae for 64 bit cpus, it's pointless
+ if [[ -n $bits ]];then
+ cpu_flags_working=$( sed 's/[[:space:]]*pae//' <<< "$cpu_flags_working" )
+ fi
+ # must have a space after last item in list for RS=" "
+ cpu_flags_working="$cpu_flags_working "
+
+ # nx = AMD stack protection extensions
+ # lm = Intel 64bit extensions
+ # sse, sse2, pni = sse1,2,3,4,5 gfx extensions
+ # svm = AMD pacifica virtualization extensions
+ # vmx = Intel IVT (vanderpool) virtualization extensions
+ cpu_flags=$( gawk '
+ BEGIN {
+ RS=" "
+ count = 0
+ i = 1 # start at one because of for increment issue
+ flag_string = ""
+ }
+
+ /^(lm|nx|pae|pni|svm|vmx|(sss|ss)e([2-9])?([a-z])?(_[0-9])?)$/ {
+ if ( $0 == "pni" ){
+ a_flags[i] = "sse3"
+ }
+ else {
+ a_flags[i] = $0
+ }
+ i++
+ }
+ END {
+ count = asort( a_flags )
+ # note: why does gawk increment before the loop and not after? weird.
+ for ( i=0; i <= count; i++ ){
+ if ( flag_string == "" ) {
+ flag_string = a_flags[i]
+ }
+ else {
+ flag_string = flag_string " " a_flags[i]
+ }
+ }
+ print flag_string
+ }' <<< "$cpu_flags_working" )
+
+ #grep -oE '\<(nx|lm|sse[0-9]?|pni|svm|vmx)\>' | tr '\n' ' '))
+ if [[ -z $cpu_flags ]];then
+ cpu_flags="-"
+ fi
+ echo "$cpu_flags"
+ log_function_data "cpu_flags: $cpu_flags"
+ eval $LOGFE
+}
+
+#### -------------------------------------------------------------------
+#### print and processing of output data
+#### -------------------------------------------------------------------
+
+#### MASTER PRINT FUNCTION - triggers all line item print functions
+## main function to print out, master for all sub print functions.
+print_it_out()
+{
+ eval $LOGFS
+ # note that print_it_out passes local variable values on to its children,
+ # and in some cases, their children, with Lspci_v_Data
+ local Lspci_v_Data='' Lspci_n_Data='' # only for verbose
+ local Sysctl_a_Data='' Dmesg_Boot_Data=''
+
+ if [[ -n $BSD_TYPE ]];then
+ Sysctl_a_Data="$( get_sysctl_data 'a' )"
+ Dmesg_Boot_Data="$( get_dmesg_boot_data )"
+ fi
+
+ if [[ $B_SHOW_SHORT_OUTPUT == 'true' ]];then
+ print_short_data
+ else
+ Lspci_v_Data="$( get_lspci_data 'v' )"
+ if [[ $B_EXTRA_EXTRA_DATA == 'true' ]];then
+ Lspci_n_Data="$( get_lspci_data 'n' )"
+ fi
+ if [[ $B_SHOW_SYSTEM == 'true' ]];then
+ print_system_data
+ fi
+ if [[ $B_SHOW_MACHINE == 'true' ]];then
+ print_machine_data
+ fi
+ if [[ $B_SHOW_WEATHER == 'true' ]];then
+ print_weather_data
+ fi
+ if [[ $B_SHOW_BASIC_CPU == 'true' || $B_SHOW_CPU == 'true' ]];then
+ print_cpu_data
+ fi
+ if [[ $B_SHOW_GRAPHICS == 'true' ]];then
+ print_graphics_data
+ fi
+ if [[ $B_SHOW_AUDIO == 'true' ]];then
+ print_audio_data
+ fi
+ if [[ $B_SHOW_NETWORK == 'true' ]];then
+ print_networking_data
+ fi
+ if [[ $B_SHOW_DISK_TOTAL == 'true' || $B_SHOW_BASIC_DISK == 'true' || $B_SHOW_DISK == 'true' ]];then
+ print_hard_disk_data
+ fi
+ if [[ $B_SHOW_PARTITIONS == 'true' ]];then
+ print_partition_data
+ fi
+ if [[ $B_SHOW_RAID == 'true' || $B_SHOW_BASIC_RAID == 'true' ]];then
+ print_raid_data
+ fi
+ if [[ $B_SHOW_UNMOUNTED_PARTITIONS == 'true' ]];then
+ print_unmounted_partition_data
+ fi
+ if [[ $B_SHOW_SENSORS == 'true' ]];then
+ print_sensors_data
+ fi
+ if [[ $B_SHOW_REPOS == 'true' ]];then
+ print_repo_data
+ fi
+ if [[ $B_SHOW_PS_CPU_DATA == 'true' || $B_SHOW_PS_MEM_DATA == 'true' ]];then
+ print_ps_data
+ fi
+ if [[ $B_SHOW_INFO == 'true' ]];then
+ print_info_data
+ fi
+ fi
+ eval $LOGFE
+}
+
+#### SHORT OUTPUT PRINT FUNCTION, ie, verbosity 0
+# all the get data stuff is loaded here to keep execution time down for single line print commands
+# these will also be loaded in each relevant print function for long output
+print_short_data()
+{
+ eval $LOGFS
+ local current_kernel=$( get_kernel_version )
+ local processes=$(( $( wc -l <<< "$Ps_aux_Data" ) - 1 ))
+ local short_data='' i='' b_background_black='false'
+ local memory=$( get_memory_data )
+ local up_time="$( get_uptime )"
+
+ # set A_CPU_CORE_DATA
+ get_cpu_core_count
+ local cpc_plural='' cpu_count_print='' model_plural=''
+ local cpu_physical_count=${A_CPU_CORE_DATA[0]}
+ local cpu_core_count=${A_CPU_CORE_DATA[3]}
+ local cpu_core_alpha=${A_CPU_CORE_DATA[1]}
+ local cpu_type=${A_CPU_CORE_DATA[2]}
+
+ if [[ $cpu_physical_count -gt 1 ]];then
+ cpc_plural='(s)'
+ model_plural='s'
+ cpu_count_print="$cpu_physical_count "
+ fi
+
+ local cpu_data_string="${cpu_count_print}${cpu_core_alpha} core"
+# local cpu_core_count=${A_CPU_CORE_DATA[0]}
+
+ # load A_HDD_DATA
+ get_hdd_data_basic
+ ## note: if hdd_model is declared prior to use, whatever string you want inserted will
+ ## be inserted first. In this case, it's desirable to print out (x) before each disk found.
+ local a_hdd_data_count=$(( ${#A_HDD_DATA[@]} - 1 ))
+ IFS=","
+ local a_hdd_basic_working=( ${A_HDD_DATA[$a_hdd_data_count]} )
+ IFS="$ORIGINAL_IFS"
+ local hdd_capacity=${a_hdd_basic_working[0]}
+ local hdd_used=${a_hdd_basic_working[1]}
+
+ # load A_CPU_DATA
+ get_cpu_data
+
+ IFS=","
+ local a_cpu_working=(${A_CPU_DATA[0]})
+ IFS="$ORIGINAL_IFS"
+ local cpu_model="${a_cpu_working[0]}"
+ ## assemble data for output
+ local cpu_clock="${a_cpu_working[1]}" # old CPU3
+ # this gets that weird min/max final array item, which almost never contains any data of use
+ local min_max_clock_nu=$(( ${#A_CPU_DATA[@]} - 1 ))
+ local min_max_clock=${A_CPU_DATA[$min_max_clock_nu]}
+ # this handles the case of for example ARM cpus, which will not have data for
+ # min/max, since they don't have speed. Since that sets a flag, not found, just
+ # look for that and use the speed from the first array array, same where we got
+ # model from
+ if [[ "$min_max_clock" == 'N/A' && ${a_cpu_working[1]} != '' ]];then
+ min_max_clock="${a_cpu_working[1]} MHz"
+ fi
+ local patch_version_number=$( get_patch_version_string )
+
+ #set_color_scheme 12
+ if [[ $B_RUNNING_IN_SHELL == 'false' ]];then
+ for i in $C1 $C2 $CN
+ do
+ case "$i" in
+ "$GREEN"|"$WHITE"|"$YELLOW"|"$CYAN")
+ b_background_black='true'
+ ;;
+ esac
+ done
+ if [[ $b_background_black == 'true' ]];then
+ for i in C1 C2 CN
+ do
+ ## these need to be in quotes, don't know why
+ if [[ ${!i} == $NORMAL ]];then
+ declare $i="${!i}15,1"
+ else
+ declare $i="${!i},1"
+ fi
+ done
+ #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}"
+
+ if [[ $SHOW_IRC -gt 0 ]];then
+ 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}"
+ if [[ $SCHEME -gt 0 ]];then
+ short_data="${short_data} $NORMAL"
+ fi
+ print_screen_output "$short_data"
+ eval $LOGFE
+}
+
+#### LINE ITEM PRINT FUNCTIONS
+
+# print sound card data
+print_audio_data()
+{
+ eval $LOGFS
+ local i='' card_id='' audio_data='' a_audio_data='' port_data='' pci_bus_id='' card_string=''
+ local a_audio_working='' audio_driver='' alsa_data='' port_plural='' module_version='' chip_id=''
+ local bus_usb_text='' bus_usb_id='' line_starter='Audio:' alsa='' alsa_version='' print_data=''
+ local driver=''
+ # set A_AUDIO_DATA and get alsa data
+ if [[ $BSD_TYPE == 'bsd' ]];then
+ if [[ $B_PCICONF_SET == 'false' ]];then
+ get_pciconf_data
+ fi
+ get_pciconf_card_data 'audio'
+ else
+ get_audio_data
+ fi
+
+ get_audio_alsa_data
+ # alsa driver data now prints out no matter what
+ if [[ -n $A_ALSA_DATA ]];then
+ IFS=","
+ if [[ -n ${A_ALSA_DATA[0]} ]];then
+ alsa=${A_ALSA_DATA[0]}
+ else
+ alsa='N/A'
+ fi
+ if [[ -n ${A_ALSA_DATA[1]} ]];then
+ alsa_version=${A_ALSA_DATA[1]}
+ else
+ alsa_version='N/A'
+ fi
+ alsa_data="${C1}Sound:${C2} $alsa ${C1}ver$SEP3${C2} $alsa_version"
+ IFS="$ORIGINAL_IFS"
+ fi
+ # note, error handling is done in the get function, so this will never be null, but
+ # leaving the test just in case it's changed.
+ if [[ -n ${A_AUDIO_DATA[@]} ]];then
+ for (( i=0; i< ${#A_AUDIO_DATA[@]}; i++ ))
+ do
+ IFS=","
+ a_audio_working=( ${A_AUDIO_DATA[i]} )
+ IFS="$ORIGINAL_IFS"
+ port_data=''
+ audio_driver=''
+ audio_data=''
+ card_string=''
+ port_plural=''
+ module_version=''
+ pci_bus_id=''
+ bus_usb_text=''
+ bus_usb_id=''
+ print_data=''
+ card_id=''
+ chip_id=''
+
+ if [[ ${#A_AUDIO_DATA[@]} -gt 1 ]];then
+ card_id="-$(( $i + 1 ))"
+ fi
+ if [[ $BSD_TYPE != 'bsd' ]];then
+ if [[ -n ${a_audio_working[3]} && $B_EXTRA_DATA == 'true' ]];then
+ module_version=$( print_module_version "${a_audio_working[3]}" 'audio' )
+ elif [[ -n ${a_audio_working[1]} && $B_EXTRA_DATA == 'true' ]];then
+ module_version=$( print_module_version "${a_audio_working[1]}" 'audio' )
+ fi
+ fi
+ # we're testing for the presence of the 2nd array item here, which is the driver name
+ if [[ -n ${a_audio_working[1]} ]];then
+ # note: linux drivers can have numbers, like tg3
+ if [[ $BSD_TYPE == 'bsd' ]];then
+ driver=$( sed 's/[0-9]$//' <<< ${a_audio_working[1]} )
+ else
+ driver=${a_audio_working[1]}
+ fi
+ 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
+ port_plural='s'
+ fi
+ port_data="${C1}port$port_plural$SEP3${C2} ${a_audio_working[2]} "
+ fi
+ if [[ -n ${a_audio_working[4]} && $B_EXTRA_DATA == 'true' ]];then
+ if [[ ${a_audio_working[1]} != 'USB Audio' ]];then
+ bus_usb_text='bus-ID'
+ if [[ $B_EXTRA_EXTRA_DATA == 'true' ]];then
+ if [[ $BSD_TYPE != 'bsd' ]];then
+ chip_id=$( get_lspci_chip_id "${a_audio_working[4]}" )
+ else
+ chip_id=${a_audio_working[6]}
+ fi
+ fi
+ else
+ bus_usb_text='usb-ID'
+ if [[ $B_EXTRA_EXTRA_DATA == 'true' ]];then
+ chip_id=${a_audio_working[5]}
+ fi
+ fi
+ bus_usb_id=${a_audio_working[4]}
+ pci_bus_id="${C1}$bus_usb_text$SEP3${C2} $bus_usb_id "
+ if [[ -n $chip_id ]];then
+ chip_id="${C1}chip-ID$SEP3${C2} $chip_id "
+ fi
+ fi
+ if [[ -n ${a_audio_working[0]} ]];then
+ card_string="${C1}Card$card_id:${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 $COLS_INNER ]];then
+ audio_data="$audio_data$alsa_data"
+ alsa_data=''
+ fi
+ fi
+ if [[ -n $audio_data ]];then
+ if [[ $( calculate_line_length "$card_string$audio_data" ) -lt $COLS_INNER ]];then
+ print_data=$( create_print_line "$line_starter" "$card_string$audio_data" )
+ print_screen_output "$print_data"
+ # print the line
+ else
+ # keep the driver on the same line no matter what, looks weird alone on its own line
+ if [[ $B_EXTRA_DATA != 'true' ]];then
+ print_data=$( create_print_line "$line_starter" "$card_string$audio_data" )
+ print_screen_output "$print_data"
+ else
+ print_data=$( create_print_line "$line_starter" "$card_string" )
+ print_screen_output "$print_data"
+ line_starter=' '
+ print_data=$( create_print_line "$line_starter" "$audio_data" )
+ print_screen_output "$print_data"
+ fi
+ fi
+ line_starter=' '
+ fi
+ done
+ 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" )
+ print_screen_output "$alsa_data"
+ fi
+ eval $LOGFE
+}
+
+print_cpu_data()
+{
+ eval $LOGFS
+ local cpu_data='' i='' cpu_clock_speed='' cpu_multi_clock_data=''
+ local bmip_data='' cpu_cache='' cpu_vendor='' cpu_flags='' flag_feature='flags'
+ 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='' line_starter=''
+
+ ##print_screen_output "A_CPU_DATA[0]=\"${A_CPU_DATA[0]}\""
+ # Array A_CPU_DATA always has one extra element: max clockfreq found.
+ # that's why its count is one more than you'd think from cores/cpus alone
+ # load A_CPU_DATA
+ get_cpu_data
+
+ IFS=","
+ a_cpu_working=(${A_CPU_DATA[0]})
+ IFS="$ORIGINAL_IFS"
+
+ # Strange (and also some expected) behavior encountered. If print_screen_output() uses $1
+ # as the parameter to output to the screen, then passing "<text1> ${ARR[@]} <text2>"
+ # will output only <text1> and first element of ARR. That "@" splits in elements and "*" _doesn't_,
+ # is to be expected. However, that text2 is consecutively truncated is somewhat strange, so take note.
+ # This has been confirmed by #bash on freenode.
+ # The above mentioned only emerges when using the debugging markers below
+ ## print_screen_output "a_cpu_working=\"***${a_cpu_working[@]} $hostName+++++++\"----------"
+ # unless all these are null, process whatever you have
+ if [[ -n ${a_cpu_working[0]} || -n ${a_cpu_working[1]} || -n ${a_cpu_working[2]} || -n ${a_cpu_working[3]} ]];then
+ cpu_model="${a_cpu_working[0]}"
+ ## assemble data for output
+ cpu_clock="${a_cpu_working[1]}"
+
+ cpu_vendor=${a_cpu_working[5]}
+
+ # set A_CPU_CORE_DATA
+ get_cpu_core_count
+ cpu_physical_count=${A_CPU_CORE_DATA[0]}
+ cpu_core_count=${A_CPU_CORE_DATA[3]}
+ cpu_core_alpha=${A_CPU_CORE_DATA[1]}
+ cpu_type=${A_CPU_CORE_DATA[2]}
+
+ if [[ $cpu_physical_count -gt 1 ]];then
+ cpc_plural='(s)'
+ cpu_count_print="$cpu_physical_count "
+ model_plural='s'
+ fi
+ line_starter="CPU$cpc_plural:"
+ 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
+ # if [[ $cpu_vendor != 'intel' ]];then
+ # ARM may use the faked 1 cpucorecount to make this work
+ # 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]}"
+ # fi
+ # bogomips are a linux thing, but my guess is over time bsds will use them somewhere anyway
+ if [[ $BSD_TYPE == 'bsd' && -z $bmip_data ]];then
+ bmip_data=''
+ else
+ 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
+ # note that we need to multiply by number of actual cpus here to get true cache size
+ if [[ -n ${a_cpu_working[2]} ]];then
+ if [[ $cpu_vendor != 'intel' ]];then
+ cpu_cache=$( calculate_multicore_data "${a_cpu_working[2]}" "$(( $cpu_core_count * $cpu_physical_count ))" )
+ else
+ cpu_cache=$( calculate_multicore_data "${a_cpu_working[2]}" "$cpu_physical_count" )
+ fi
+ else
+ cpu_cache='N/A'
+ fi
+ # only print shortened list
+ if [[ $B_CPU_FLAGS_FULL != 'true' ]];then
+ # gawk has already sorted this output, no flags returns -
+ 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
+ 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${CN}"
+ cpu_2_data="$cpu_flags$bmip_data${CN}"
+ else
+ cpu_data="$cpu_data${C2} (ARM)$bmip_data${CN}"
+ 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}"
+ fi
+ 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="${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}" ):
+# 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}" )
+ line_starter=''
+ print_screen_output "$cpu_data"
+ cpu_data=$( create_print_line " " "${cpu_2_data}" )
+ print_screen_output "$cpu_data"
+ else
+ cpu_data=$( create_print_line "$line_starter" "${cpu_data}" )
+ print_screen_output "$cpu_data ${cpu_2_data}"
+ fi
+ # 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
+ for (( i=0; i < ${#A_CPU_DATA[@]}-1; i++ ))
+ do
+ IFS=","
+ 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
+ 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
+ if [[ $B_CPU_FLAGS_FULL == 'true' ]];then
+ print_cpu_flags_full "${a_cpu_working[3]}" "${a_cpu_working[6]}"
+ fi
+ eval $LOGFE
+}
+
+# takes list of all flags, split them and prints x per line
+# args: $1 - cpu flag string; $2 - arm true/false
+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_string=''
+ local i=0 counter=0 starter_length=15 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
+ temp_string="$flag_string$spacer$flag"
+ spacer=' '
+ # handle inner line starter
+ if [[ $counter -gt 0 ]];then
+ line_length=$COLS_INNER
+ fi
+ 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 -gt 0 ]];then
+ line_starter=''
+ fi
+ flag_data=$( create_print_line " " "$line_starter${a_cpu_flags[$i]}" )
+ print_screen_output "$flag_data"
+ done
+ eval $LOGFE
+}
+
+print_graphics_data()
+{
+ eval $LOGFS
+ local graphics_data='' card_id='' i='' root_alert='' root_x_string='' a_graphics_working=''
+ local b_is_mesa='false' display_full_string='' card_bus_id='' card_data=''
+ local res_tty='Resolution' xorg_data='' display_vendor_string='' chip_id=''
+ 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 screen_resolution="$( get_graphics_res_data )"
+
+ # set A_DISPLAY_SERVER_DATA
+ get_graphics_display_server_data
+ local display_vendor=${A_DISPLAY_SERVER_DATA[0]}
+ local display_version=${A_DISPLAY_SERVER_DATA[1]}
+ # set A_GLX_DATA
+ get_graphics_glx_data
+ local glx_renderer="${A_GLX_DATA[0]}"
+ local glx_version="${A_GLX_DATA[1]}"
+ # this can contain a long No case debugging message, so it's being sliced off
+ # note: using grep -ioE '(No|Yes)' <<< ${A_GLX_DATA[2]} did not work in Arch, no idea why
+ local glx_direct_render=$( gawk '{print $1}' <<< "${A_GLX_DATA[2]}" )
+
+ # set A_GRAPHICS_CARD_DATA
+ if [[ $BSD_TYPE == 'bsd' ]];then
+ if [[ $B_PCICONF_SET == 'false' ]];then
+ get_pciconf_data
+ fi
+ get_pciconf_card_data 'display'
+ else
+ get_graphics_card_data
+ fi
+ # set A_GRAPHIC_DRIVERS
+ get_graphics_driver
+
+ if [[ ${#A_GRAPHIC_DRIVERS[@]} -eq 0 ]];then
+ driver=' N/A'
+ else
+ for (( i=0; i < ${#A_GRAPHIC_DRIVERS[@]}; i++ ))
+ do
+ IFS=","
+ a_graphics_working=( ${A_GRAPHIC_DRIVERS[i]} )
+ IFS="$ORIGINAL_IFS"
+ case ${a_graphics_working[1]} in
+ loaded)
+ loaded="$loaded$separator_loaded${a_graphics_working[0]}"
+ separator_loaded=','
+ ;;
+ unloaded)
+ unloaded="$unloaded$separator_unloaded${a_graphics_working[0]}"
+ separator_unloaded=','
+ ;;
+ failed)
+ failed="$failed$separator_failed${a_graphics_working[0]}"
+ separator_failed=','
+ ;;
+ esac
+ done
+ fi
+ if [[ -n $loaded ]];then
+ driver="${driver} $loaded"
+ fi
+ if [[ -n $unloaded ]];then
+ driver="${driver} (unloaded: $unloaded)"
+ fi
+ if [[ -n $failed ]];then
+ driver="${driver} ${RED}FAILED:${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
+ 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 "
+
+ if [[ $B_ROOT == 'true' ]];then
+ root_x_string='for root '
+ if [[ $B_RUNNING_IN_SHELL == 'true' || $B_CONSOLE_IRC == 'true' ]];then
+ res_tty='tty size'
+ fi
+ fi
+ if [[ $B_RUNNING_IN_DISPLAY != 'true' ]];then
+ root_x_string="${root_x_string}out of X"
+ res_tty='tty size'
+ fi
+
+ if [[ -n $root_x_string ]];then
+ root_x_string="${C1}Advanced Data:${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
+ IFS=","
+ a_graphics_working=( ${A_GRAPHICS_CARD_DATA[i]} )
+ IFS="$ORIGINAL_IFS"
+ card_bus_id=''
+ 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]}"
+ if [[ $B_EXTRA_EXTRA_DATA == 'true' ]];then
+ if [[ $BSD_TYPE != 'bsd' ]];then
+ chip_id=$( get_lspci_chip_id "${a_graphics_working[1]}" )
+ else
+ chip_id=${a_graphics_working[2]}
+ fi
+ fi
+ else
+ card_bus_id=" ${C1}bus-ID$SEP3${C2} N/A"
+ fi
+ fi
+ if [[ -n $chip_id ]];then
+ 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:'
+ fi
+ graphics_data="${C1}$card_id${C2} $card_data$card_bus_id$chip_id "
+ if [[ ${#A_GRAPHICS_CARD_DATA[@]} -gt 1 ]];then
+ graphics_data=$( create_print_line "$line_starter" "${graphics_data}" )
+ print_screen_output "$graphics_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! "
+ fi
+ if [[ -n $graphics_data && $( calculate_line_length "${graphics_data}$display_full_string" ) -lt $COLS_INNER ]];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" )
+ print_screen_output "$graphics_data"
+ line_starter=' '
+ fi
+ graphics_data=$( create_print_line "$line_starter" "$display_full_string" )
+ fi
+ print_screen_output "$graphics_data"
+ # if [[ -z $glx_renderer || -z $glx_version ]];then
+ # b_is_mesa='true'
+ # fi
+
+ ## note: if glx render or display_version have no content, then mesa is true
+ # if [[ $B_SHOW_DISPLAY_DATA == 'true' ]] && [[ $b_is_mesa != 'true' ]];then
+ if [[ $B_SHOW_DISPLAY_DATA == 'true' && $B_ROOT != 'true' ]];then
+ if [[ -z $glx_renderer ]];then
+ glx_renderer='N/A'
+ fi
+ if [[ -z $glx_version ]];then
+ glx_version='N/A'
+ fi
+ if [[ -z $glx_direct_render ]];then
+ 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}"
+ 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" )
+
+ print_screen_output "$graphics_data"
+ fi
+ eval $LOGFE
+}
+
+print_hard_disk_data()
+{
+ eval $LOGFS
+ local hdd_data='' hdd_data_2='' a_hdd_working='' hdd_temp_data='' hdd_string=''
+ local hdd_serial=''
+ local dev_data='' size_data='' hdd_model='' usb_data='' hdd_name='' divisor=5
+ local Line_Starter='Drives:' # inherited by print_optical_drives
+
+ # load A_HDD_DATA
+ get_hdd_data_basic
+ ## note: if hdd_model is declared prior to use, whatever string you want inserted will
+ ## be inserted first. In this case, it's desirable to print out (x) before each disk found.
+ local a_hdd_data_count=$(( ${#A_HDD_DATA[@]} - 1 ))
+ IFS=","
+ local a_hdd_basic_working=( ${A_HDD_DATA[$a_hdd_data_count]} )
+ IFS="$ORIGINAL_IFS"
+ local hdd_capacity="${a_hdd_basic_working[0]}"
+ local hdd_used=${a_hdd_basic_working[1]}
+ local bsd_unsupported='Hard drive data not yet supported for BSD systems.'
+ local hdd_name_temp=''
+
+ if [[ $B_SHOW_BASIC_DISK == 'true' || $B_SHOW_DISK == 'true' ]];then
+ ## note: the output part of this should be in the print hdd data function, not here
+ get_hard_drive_data_advanced
+ for (( i=0; i < ${#A_HDD_DATA[@]} - 1; i++ ))
+ do
+ # this adds the (x) numbering in front of each disk found, and creates the full disk string
+ IFS=","
+ a_hdd_working=( ${A_HDD_DATA[i]} )
+ IFS="$ORIGINAL_IFS"
+ if [[ $B_SHOW_DISK == 'true' ]];then
+ if [[ -n ${a_hdd_working[3]} ]];then
+ usb_data="${a_hdd_working[3]} "
+ else
+ usb_data=''
+ fi
+ dev_data="/dev/${a_hdd_working[0]} "
+ size_data=" ${C1}size$SEP3${C2} ${a_hdd_working[1]}"
+ if [[ $B_EXTRA_DATA == 'true' && -n $dev_data ]];then
+ hdd_temp_data=$( get_hdd_temp_data "$dev_data" )
+ # error handling is done in get data function
+ if [[ -n $hdd_temp_data ]];then
+ hdd_temp_data=" ${C1}temp$SEP3${C2} ${hdd_temp_data}C"
+ else
+ hdd_temp_data=''
+ fi
+ fi
+ if [[ $B_EXTRA_EXTRA_DATA == 'true' ]];then
+ hdd_serial=$( get_hdd_serial_number "${a_hdd_working[0]}" )
+ if [[ -z $hdd_serial ]];then
+ hdd_serial='N/A'
+ fi
+ hdd_serial=" ${C1}serial$SEP3${C2} $hdd_serial"
+ divisor=1 # print every line
+ else
+ divisor=2 # for modulus line print out, either 2 items for full, or default for short
+ fi
+ dev_data="${C1}id$SEP3${C2} /dev/${a_hdd_working[0]} "
+ fi
+ if [[ -n ${a_hdd_working[2]} ]];then
+ hdd_name_temp=${a_hdd_working[2]}
+ else
+ hdd_name_temp='N/A'
+ 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 "
+ # 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})" )
+ print_screen_output "$hdd_data"
+ Line_Starter=' '
+ 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}" )
+ print_screen_output "$hdd_data"
+ hdd_model=''
+ Line_Starter=' '
+ fi
+ ;;
+ *)
+ # 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}" )
+ print_screen_output "$hdd_data"
+ hdd_model=''
+ Line_Starter=' '
+ fi
+ ;;
+ esac
+ done
+ # then print any leftover items
+ if [[ -n $hdd_model ]];then
+ hdd_data=$( create_print_line "$Line_Starter" "${hdd_model}${CN}" )
+ print_screen_output "$hdd_data"
+ fi
+ # temporary message to indicate not yet supported
+ if [[ $BSD_TYPE == 'bsd' ]];then
+ hdd_data=$bsd_unsupported
+ hdd_data=$( create_print_line "$Line_Starter" "$hdd_data${CN}" )
+ print_screen_output "$hdd_data"
+ Line_Starter=' '
+ fi
+ else
+ # temporary message to indicate not yet supported
+ hdd_data="${C1}HDD Total Size:${C2} ${hdd_capacity} (${hdd_used})"
+ if [[ $BSD_TYPE == 'bsd' ]];then
+ hdd_data=$bsd_unsupported
+ fi
+ hdd_data=$( create_print_line "$Line_Starter" "$hdd_data${CN}" )
+ print_screen_output "$hdd_data"
+ Line_Starter=' '
+ fi
+ if [[ $B_SHOW_FULL_OPTICAL == 'true' || $B_SHOW_BASIC_OPTICAL == 'true' ]];then
+ print_optical_drive_data
+ fi
+
+ eval $LOGFE
+}
+
+print_info_data()
+{
+ eval $LOGFS
+
+ local info_data='' line_starter='Info:' runlvl_default='' runlvl='' runlvl_title='runlevel'
+ local init_data='' init_type='' init_version='' rc_type='' rc_version=''
+ local client_data='' shell_data='' shell_parent='' tty_session=''
+ local memory="$( get_memory_data )"
+ local processes=$(( $( wc -l <<< "$Ps_aux_Data" ) - 1 ))
+ local up_time="$( get_uptime )"
+ local patch_version_number=$( get_patch_version_string )
+ local gcc_string='' gcc_installed='' gcc_others='' closing_data=''
+
+ if [[ -z $memory ]];then
+ memory='N/A'
+ fi
+
+ if [[ $B_EXTRA_DATA == 'true' ]];then
+ get_gcc_system_version
+ if [[ ${#A_GCC_VERSIONS[@]} -gt 0 ]];then
+ if [[ -n ${A_GCC_VERSIONS[0]} ]];then
+ gcc_installed=${A_GCC_VERSIONS[0]}
+ else
+ 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]} )"
+ fi
+ gcc_installed="${C1}Gcc sys$SEP3${C2} $gcc_installed$gcc_others "
+ fi
+ fi
+ if [[ $B_RUNNING_IN_SHELL == 'true' ]];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.
+ if [[ $B_EXTRA_EXTRA_DATA == 'true' ]];then
+ if [[ $B_RUNNING_IN_DISPLAY != 'true' ]];then
+ shell_parent=$( get_tty_number )
+ shell_parent="tty $shell_parent"
+ else
+ shell_parent=$( get_shell_parent )
+ fi
+ if [[ $shell_parent == 'login' ]];then
+ shell_parent=''
+ elif [[ -n $shell_parent ]];then
+ shell_parent=" running in $shell_parent"
+ fi
+ fi
+ IRC_CLIENT="$IRC_CLIENT ($shell_data$shell_parent)"
+ fi
+ 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} "
+
+ # 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
+ get_init_data
+ if [[ ${A_INIT_DATA[0]} == 'systemd' && -z $( grep -E '^[0-9]$' <<< ${A_INIT_DATA[4]} ) ]];then
+ runlvl_title='target'
+ fi
+ init_type=${A_INIT_DATA[0]}
+ if [[ -z $init_type ]];then
+ init_type='N/A'
+ fi
+
+ if [[ $B_EXTRA_EXTRA_DATA == 'true' ]];then
+ init_version=${A_INIT_DATA[1]}
+ if [[ -z $init_version ]];then
+ init_version='N/A'
+ fi
+ init_version=" ${C1}v$SEP3${C2} $init_version"
+ rc_version=${A_INIT_DATA[3]}
+ if [[ -n $rc_version ]];then
+ rc_version=" ${C1}v$SEP3${C2} $rc_version"
+ fi
+
+ runlvl_default=${A_INIT_DATA[5]}
+ fi
+ # currently only using openrc here, otherwise show nothing
+ rc_type=${A_INIT_DATA[2]}
+ if [[ -n $rc_type ]];then
+ rc_type=" ${C1}rc$SEP3${C2} $rc_type$rc_version"
+ fi
+ init_type="${C1}Init$SEP3${C2} $init_type$init_version "
+
+ runlvl=${A_INIT_DATA[4]}
+ if [[ -n $runlvl ]];then
+ runlvl="${C1}$runlvl_title$SEP3${C2} $runlvl "
+ fi
+ if [[ -n $runlvl_default ]];then
+ runlvl_default="${C1}default$SEP3${C2} $runlvl_default "
+ fi
+ 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} "
+ fi
+ info_data="${info_data}"
+ closing_data="$client_data${C1}$SCRIPT_NAME$SEP3${C2} $SCRIPT_VERSION_NUMBER$patch_version_number${CN}"
+
+ # 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 $COLS_INNER ]];then
+ info_data=${info_data}${init_data}
+ info_data=$( create_print_line "$line_starter" "$info_data" )
+ 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 $COLS_INNER ]];then
+ info_data=${info_data}${init_data}${gcc_installed}
+ info_data=$( create_print_line "$line_starter" "$info_data" )
+ print_screen_output "$info_data"
+ info_data=''
+ gcc_installed=''
+ init_data=''
+ line_starter=' '
+ #echo 2
+ fi
+ info_data="${info_data}${init_data}${gcc_installed}${closing_data}"
+
+ info_data=$( create_print_line "$line_starter" "$info_data" )
+ if [[ $SCHEME -gt 0 ]];then
+ info_data="${info_data} ${NORMAL}"