(no version change: branche one)

Testing new swap data, nice one damentz
This commit is contained in:
inxi-svn 2009-03-02 00:20:52 +00:00
parent 57073c23a1
commit fec6480dd9

89
inxi
View file

@ -1,8 +1,8 @@
#!/bin/bash
########################################################################
#### Script Name: inxi
#### version: 1.0.3-b1-t3
#### Date: 17 February 2009
#### version: 1.0.4-b1-t1
#### Date: 1 March 2009
########################################################################
#### SPECIAL THANKS
########################################################################
@ -21,6 +21,7 @@
#### Copyright (C) 2005-2007 Michiel de Boer a.k.a. locsmif
#### inxi version: Copyright (C) 2008-9 Scott Rogers & Harald Hope
#### Further fixes (listed as known): Horst Tritremmel <hjt at sidux.com>
#### Steven Barrett (aka: damentz) - usb audio patch;
####
#### Current script home page: http://techpatterns.com/forums/about1131.html
#### Script svn: http://code.google.com/p/inxi
@ -105,6 +106,8 @@
#### -! 10 - triggers an update from the primary dev download server instead of svn
#### -! 11 - triggers an update from svn branch one - if present, of course
#### -! 12 - triggers an update from svn branch two - if present, of course
#### -! 13 - triggers an update from svn branch three - if present, of course
#### -! 14 - triggers an update from svn branch four - if present, of course
#### -! <http://......> - Triggers an update from whatever server you list.
########################################################################
#### VARIABLES
@ -247,6 +250,8 @@ SCRIPT_VERSION_NUMBER=$( grep -im 1 'version:' $SCRIPT_PATH/$SCRIPT_NAME | gawk
SCRIPT_DOWNLOAD='http://inxi.googlecode.com/svn/trunk/'
SCRIPT_DOWNLOAD_BRANCH_1='http://inxi.googlecode.com/svn/branches/one/'
SCRIPT_DOWNLOAD_BRANCH_2='http://inxi.googlecode.com/svn/branches/two/'
SCRIPT_DOWNLOAD_BRANCH_3='http://inxi.googlecode.com/svn/branches/three/'
SCRIPT_DOWNLOAD_BRANCH_4='http://inxi.googlecode.com/svn/branches/four/'
SCRIPT_DOWNLOAD_DEV='http://smxi.org/test/'
KONVI_CFG="konversation/scripts/$SCRIPT_NAME.conf" # relative path to $(kde-config --path data)
@ -904,11 +909,20 @@ get_parameters()
3) B_TESTING_1='true'
B_TESTING_2='true'
;;
10) script_self_updater "$SCRIPT_DOWNLOAD_DEV" 'dev server'
10)
script_self_updater "$SCRIPT_DOWNLOAD_DEV" 'dev server'
;;
11) script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_1" 'svn: branch one server'
11)
script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_1" 'svn: branch one server'
;;
12) script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_2" 'svn: branch two server'
12)
script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_2" 'svn: branch two server'
;;
13)
script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_3" 'svn: branch three server'
;;
14)
script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_4" 'svn: branch four server'
;;
http*)
script_self_updater "$OPTARG" 'alt server'
@ -999,6 +1013,8 @@ show_options()
print_screen_output "-! 10 - Triggers an update from the primary dev download server instead of svn."
print_screen_output "-! 11 - Triggers an update from svn branch one - if present, of course."
print_screen_output "-! 12 - Triggers an update from svn branch two - if present, of course."
print_screen_output "-! 13 - Triggers an update from svn branch three - if present, of course."
print_screen_output "-! 14 - Triggers an update from svn branch four - if present, of course."
print_screen_output "-! <http://......> - Triggers an update from whatever server you list."
print_screen_output ""
fi
@ -1381,24 +1397,22 @@ get_audio_data()
for usb_proc_file in /proc/asound/*
do
# if lsusb exists, the file is a symlink, and contains an important usb exclusive file: continue
if [[ -n "$( which lsusb )" && -L "$usb_proc_file" && -e "$usb_proc_file/usbid" ]]; then
if [[ -n $( which lsusb ) && -L $usb_proc_file && -e $usb_proc_file/usbid ]]; then
# send error messages of lsusb to /dev/null as it will display a bunch if not a super user
# also, find the contents of usbid in lsusb and print everything after the 7th word on the corresponding line
# finally, strip out commas as they will change the driver :)
# lsusb is not contained in some users paths, hardcode it!
# also, find the contents of usbid in lsusb and print everything after the 7th word on the
# corresponding line. Finally, strip out commas as they will change the driver :)
usb_id=$( cat $usb_proc_file/usbid )
usb_data=$( lsusb -v 2>/dev/null | grep "$usb_id" )
usb_data=$( gawk '{
gsub(/,/, " ", $0)
for( i=7; i<NF; i++) {
printf($i " ")
gsub( /,/, " ", $0 )
for( i=7; i <= NF; i++ ) {
printf( $i " " )
}
#printf "\n"
}' <<< "$usb_data" )
# this method is interesting, it shouldn't work but it does
#A_AUDIO_DATA=( "${A_AUDIO_DATA[@]}" "$usb_data,snd-usb-audio,," )
# but until we learn why the above worked, I'm using this one, which is safer
if [[ -n "$usb_data" ]];then
if [[ -n $usb_data ]];then
array_count=${#A_AUDIO_DATA[@]}
A_AUDIO_DATA[$array_count]="$usb_data,snd-usb-audio,,"
fi
@ -1835,8 +1849,8 @@ get_graphics_glx_data()
function join(arr, sep) {
s=""
i=flag=0
for (i in arr) {
if (flag++) {
for ( i in arr ) {
if ( flag++ ) {
s = s sep
}
s = s i
@ -1848,9 +1862,9 @@ get_graphics_glx_data()
IGNORECASE=1
}
/opengl renderer/ {
if ($2 ~ /mesa/) {
if ( $2 ~ /mesa/ ) {
# Allow r300 et al, but not the rest
if ($2 ~ / r[3-9][0-9][0-9] /) {
if ( $2 ~ / r[3-9][0-9][0-9] / ) {
a[$2]
f++
}
@ -1858,7 +1872,7 @@ get_graphics_glx_data()
}
$2 && a[$2]
}
/opengl version/ && (f || $2 !~ /mesa/) {
/opengl version/ && ( f || $2 !~ /mesa/ ) {
$2 && b[$2]
}
/direct rendering/ {
@ -1971,13 +1985,13 @@ get_hdd_data_basic()
{
local hdd_used=''
hdd_used=$( df | gawk '
hdd_used=$( df --exclude-type=aufs --exclude-type=tmpfs --exclude-type=iso9660 | gawk '
# also handles odd dm-1 type, from lvm
/^\/dev\/(mapper\/|[hs]d[a-z][0-9]+|dm[-]?[0-9]+)/ {
# this handles the case where the first item is too long
# and makes df wrap output to next line, so here we advance
# it to the next line for that single case
if ( NF == 1 ) {
if ( NF < 5 && $0 !~ /.*\%/ ) {
getline
}
# if the first item caused a wrap, use one less than standard
@ -2010,7 +2024,8 @@ get_hdd_data_basic()
IFS=$'\n'
if [[ $B_PARTITIONS_DIR == 'true' ]];then
A_HDD_DATA=( $( gawk -v hddused="$hdd_used" '
A_HDD_DATA=( $(
gawk -v hddused="$hdd_used" '
/[hs]d[a-z]$/ {
driveSize = $(NF - 1)*1024/1000**3
gsub(/,/, " ", driveSize)
@ -2018,11 +2033,14 @@ get_hdd_data_basic()
printf( $NF",%.1fGB,,\n", driveSize )
}
# See http://lanana.org/docs/device-list/devices-2.6+.txt for major numbers used below
# $1 ~ /^(3|22|33|8)$/ && $2 % 16 == 0 {size+=$3}
# $1 ~ /^(3|22|33|8)$/ && $2 % 16 == 0 {
# size += $3
# }
# special case from this data: 8 0 156290904 sda
$1 ~ /^(3|22|33|8)$/ && $NF ~ /[hs]d[a-z]$/ && ( $2 % 16 == 0 || $2 % 16 == 8 ) {
size += $3
}
END {
size = size*1024/1000**3 # calculate size in GB size
workingUsed = hddused*1024/1000**3 # calculate workingUsed in GB used
@ -2040,7 +2058,8 @@ get_hdd_data_basic()
else {
print "NA,-" # print an empty array, this will be further handled in the print out function
}
}' $DIR_PARTITIONS ) )
}' $DIR_PARTITIONS
) )
fi
IFS="$ORIGINAL_IFS"
}
@ -2352,7 +2371,7 @@ get_partition_data()
# $NF = partition name; $(NF - 4) = partition size; $(NF - 3) = used, in gB; $(NF - 1) = percent used
## note: by subtracting from the last field number NF, we avoid a subtle issue with LVM df output, where if
## the first field is too long, it will occupy its own line, this way we are getting only the needed data
A_PARTITION_DATA=( $( df -h -T --exclude-type=aufs --exclude-type=tmpfs --exclude-type=iso9660 | gawk '
A_PARTITION_DATA=( $( df -h -T --exclude-type=aufs --exclude-type=tmpfs --exclude-type=iso9660 | gawk '
BEGIN {
IGNORECASE=1
}
@ -2387,11 +2406,20 @@ get_partition_data()
' )
# now add the swap partition data, doesn't show percent used, someone can figure that in the future
# don't want to show swap files, just partitions
$( swapon -s | gawk '
/^\/dev\/[hs]d[a-z]/ {
# $( swapon -s | gawk '
# /^\/dev\/[hs]d[a-z]/ {
# size = sprintf( "%.2f", $3*1024/1000**3 )
# devBase = gensub( /^(\/dev\/)(.+)$/, "\\2", 1, $1 )
# print $1 "," size "GB,,,swap," devBase
# }' ) )
$( cat /proc/swaps | grep /dev | gawk '
/^\/dev/ {
size = sprintf( "%.2f", $3*1024/1000**3 )
devBase = gensub( /^(\/dev\/)(.+)$/, "\\2", 1, $1 )
print $1 "," size "GB,,,swap," devBase
used = sprintf( "%.2f", $4*1024/1000**3 )
percentUsed = sprintf( "%.0f", ( $4/$3 )*100 )
print "swap," size "GB," used "GB," percentUsed "\%,main," devBase
}' ) )
IFS="$ORIGINAL_IFS"
@ -2430,6 +2458,8 @@ get_partition_data_advanced()
partition = ""
partTemp = ""
}
# trying to handle space in name
# gsub( /\\040/, " ", $0 )
/[ \t]'$mount_point'[ \t]/ && $1 != "rootfs" {
# initialize the variables
label = ""
@ -2498,6 +2528,9 @@ get_partition_data_advanced()
}' )
elif [[ -n $dev_disk_label ]] && [[ -z $dev_item && -n $dev_label ]];then
dev_item=$( echo "$dev_disk_label" | gawk '
# first we need to change space x20 in by-label back to a real space
#gsub( /x20/, " ", $0 )
# then we can see if the string is there
/'$dev_label'/ {
item=gensub( /..\/..\/(.+)/, "\\1", 1, $NF )
print item