A few major changes: in get client data, got rid of loose detections like *xchat* or *sh* and replaced them with tight,

literals in the case list. This might trigger a few failures, but it's better to then handle those failures explicitly in 
my opinion than to depend on something as loose as *sh*, which will catch any app with sh ever made.

Moved advanced hard disk data to be triggered now by -H, to avoid spamming irc. 

In the future, -x, extra data, will only be used for really silly little things like bogomips, ports, and so on, stuff 
that's short and basically just of interest to a few people.
This commit is contained in:
inxi-svn 2008-11-09 19:51:33 +00:00
parent b1fa122748
commit d611c88df5

69
inxi
View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
######################################################################## ########################################################################
#### Script Name: inxi #### Script Name: inxi
#### version: 0.4.20 #### version: 0.4.21
#### Date: November 8 2008 #### Date: November 8 2008
######################################################################## ########################################################################
#### inxi is a fork of infobash, the original bash sys info script by locsmif #### inxi is a fork of infobash, the original bash sys info script by locsmif
@ -13,6 +13,7 @@
#### Original infobash author and copyright holder: #### Original infobash author and copyright holder:
#### Copyright (C) 2005-2007 Michiel de Boer a.k.a. locsmif <infobash@rebelhomicide.demon.nl> #### Copyright (C) 2005-2007 Michiel de Boer a.k.a. locsmif <infobash@rebelhomicide.demon.nl>
#### inxi version: Copyright (C) 2008 Warren Scott Rogers & Harald Hope #### inxi version: Copyright (C) 2008 Warren Scott Rogers & Harald Hope
#### Further fixes (listed as known): Horst Tritremmel <hjt at sidux.com>
#### ####
#### Current script home page: http://techpatterns.com/forums/about1131.html #### Current script home page: http://techpatterns.com/forums/about1131.html
#### Script svn: http://code.google.com/p/inxi #### Script svn: http://code.google.com/p/inxi
@ -75,6 +76,8 @@ B_EXTRA_DATA='false'
B_HANDLE_CORRUPT_DATA='false' B_HANDLE_CORRUPT_DATA='false'
# Running in a shell? Defaults to false, and is determined later. # Running in a shell? Defaults to false, and is determined later.
B_RUNNING_IN_SHELL='false' B_RUNNING_IN_SHELL='false'
# Show full hard disk output
B_SHOW_FULL_HDD='false'
# Set this to 'false' to avoid printing the hostname # Set this to 'false' to avoid printing the hostname
B_SHOW_HOST='true' B_SHOW_HOST='true'
# Show sound card data # Show sound card data
@ -455,7 +458,7 @@ get_parameters()
return 1 return 1
fi fi
while getopts c:CdDfFhsTUv:Vx opt while getopts c:CdDfFhHsTUv:Vx opt
do do
case $opt in case $opt in
c) if [[ -n $( egrep '^[0-9][0-9]?$' <<< $OPTARG ) ]];then c) if [[ -n $( egrep '^[0-9][0-9]?$' <<< $OPTARG ) ]];then
@ -480,9 +483,12 @@ get_parameters()
;; ;;
F) VERBOSITY_LEVEL=$VERBOSITY_LEVELS F) VERBOSITY_LEVEL=$VERBOSITY_LEVELS
B_CPU_FLAGS_FULL='true' B_CPU_FLAGS_FULL='true'
B_SHOW_FULL_HDD='true'
B_SHOW_SOUND='true' B_SHOW_SOUND='true'
B_EXTRA_DATA='true' B_EXTRA_DATA='true'
;; ;;
H) B_SHOW_FULL_HDD='true'
;;
s) B_SHOW_SOUND='true' s) B_SHOW_SOUND='true'
;; ;;
T) B_TESTING_FLAG='true' T) B_TESTING_FLAG='true'
@ -525,6 +531,7 @@ show_options()
print_screen_output "-d Default output verbosity level, same as: $SCRIPT_NAME -v 1" print_screen_output "-d Default output verbosity level, same as: $SCRIPT_NAME -v 1"
print_screen_output "-f Show all cpu flags used, not just the short list." print_screen_output "-f Show all cpu flags used, not just the short list."
print_screen_output "-F Show Full, all possible, output for $SCRIPT_NAME." print_screen_output "-F Show Full, all possible, output for $SCRIPT_NAME."
print_screen_output "-h Show full hard disk info, not only model, ie: /dev/sda - ST380817AS - 80.0GB."
print_screen_output "-s Show sound card information." print_screen_output "-s Show sound card information."
print_screen_output "-U Autoupdate script. Note: if you installed as root, you" print_screen_output "-U Autoupdate script. Note: if you installed as root, you"
print_screen_output " must be root to update, otherwise user is fine." print_screen_output " must be root to update, otherwise user is fine."
@ -590,7 +597,7 @@ script_self_updater()
get_start_client() get_start_client()
{ {
local irc_client_path='' irc_client_path_lower='' non_native_konvi='' i='' local irc_client_path='' irc_client_path_lower='' non_native_konvi='' i=''
local b_non_native_app='false' pppid='' local b_non_native_app='false' pppid='' app_working_name=''
if tty >/dev/null;then if tty >/dev/null;then
IRC_CLIENT='Shell' IRC_CLIENT='Shell'
@ -599,35 +606,29 @@ get_start_client()
elif [[ -n $PPID && -f /proc/$PPID/exe ]];then elif [[ -n $PPID && -f /proc/$PPID/exe ]];then
irc_client_path=$( readlink /proc/$PPID/exe ) irc_client_path=$( readlink /proc/$PPID/exe )
irc_client_path_lower=$( tr '[:upper:]' '[:lower:]' <<< $irc_client_path ) irc_client_path_lower=$( tr '[:upper:]' '[:lower:]' <<< $irc_client_path )
# from sidux infobash, handle bad detection of shell; Horst Tritremmel <hjt at sidux.com> app_working_name=$( basename $irc_client_path_lower )
# note: do NOT put into '' or "" the dash|bash\perl stuff, otherwise the structure fails # handles the xchat/sh/bash/dash cases, and the konversation/perl cases, where clients
# handles the xchat/sh/bash/dash cases, and the konversation/perl cases, where # report themselves as perl or unknown shell. IE: when konversation starts inxi
# konversation reports itself as perl, which was missed because when konversation starts inxi # from inside itself, as a script, the parent is konversation/xchat, not perl/bash etc
# from inside itself, as a script, the parent is konversation, not perl case $app_working_name in
## note: this method: [[ ${irc_client_path_lower##*/} =~ dash|bash|sh|perl ]] fails in older bash, etch
case ${irc_client_path_lower##*/} in
bash|dash|sh|perl) # We want to know who wrapped it into the shell or perl. bash|dash|sh|perl) # We want to know who wrapped it into the shell or perl.
pppid="$( ps -p $PPID -o ppid --no-headers | sed 's/ //g' )" pppid="$( ps -p $PPID -o ppid --no-headers | sed 's/ //g' )"
if [[ -n $pppid && -f /proc/$pppid/exe ]];then if [[ -n $pppid && -f /proc/$pppid/exe ]];then
irc_client_path="$( readlink /proc/$pppid/exe )" irc_client_path="$( readlink /proc/$pppid/exe )"
irc_client_path_lower="$( tr '[:upper:]' '[:lower:]' <<< $irc_client_path )" irc_client_path_lower="$( tr '[:upper:]' '[:lower:]' <<< $irc_client_path )"
app_working_name=$( basename $irc_client_path_lower )
b_non_native_app='true' b_non_native_app='true'
fi fi
;; ;;
esac esac
# replacing this fix with the one above, which is more globally affective # replacing loose detection with tight detection, bugs will be handled with app names
# if [[ -z $( grep -i 'konversation' <<< $irc_client_path ) && -n $( grep -i 'perl' <<< $irc_client_path ) && -n $( pidof konversation ) ]];then # as they appear.
# irc_client_path=$( which konversation ) case $app_working_name in
# irc_client_path_lower=$( tr '[:upper:]' '[:lower:]' <<< $irc_client_path ) irssi-text|irssi)
# non_native_konvi='true'
# fi
case $irc_client_path_lower in
*irssi-text*|*irssi*)
IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 { print $2 }' )" IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 { print $2 }' )"
IRC_CLIENT="Irssi" IRC_CLIENT="Irssi"
;; ;;
*konversation*) konversation)
# this is necessary to avoid the dcop errors from starting inxi as a /cmd started script # this is necessary to avoid the dcop errors from starting inxi as a /cmd started script
if [[ $b_non_native_app == 'true' ]];then if [[ $b_non_native_app == 'true' ]];then
KONVI=2 KONVI=2
@ -674,15 +675,15 @@ get_start_client()
fi fi
IRC_CLIENT="Konversation" IRC_CLIENT="Konversation"
;; ;;
*xchat-gnome) xchat-gnome)
IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 { print $2 }' )" IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 { print $2 }' )"
IRC_CLIENT="X-Chat-Gnome" IRC_CLIENT="X-Chat-Gnome"
;; ;;
*xchat*) xchat)
IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 { print $2 }' )" IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 { print $2 }' )"
IRC_CLIENT="X-Chat" IRC_CLIENT="X-Chat"
;; ;;
*bitchx*) bitchx)
IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk ' IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk '
/Version/ { /Version/ {
a=tolower($2) a=tolower($2)
@ -698,23 +699,23 @@ get_start_client()
}' )" }' )"
IRC_CLIENT="BitchX" IRC_CLIENT="BitchX"
;; ;;
*ircii*) ircii)
IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 { print $3 }' )" IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 { print $3 }' )"
IRC_CLIENT="ircII" IRC_CLIENT="ircII"
;; ;;
*gaim*) gaim)
IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 { print $2 }' )" IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 { print $2 }' )"
IRC_CLIENT="Gaim" IRC_CLIENT="Gaim"
;; ;;
*pidgin*) pidgin)
IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 { print $2 }' )" IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 { print $2 }' )"
IRC_CLIENT="Pidgin" IRC_CLIENT="Pidgin"
;; ;;
*weechat-curses*) weechat-curses)
IRC_CLIENT_VERSION=" $( $irc_client_path -v) " IRC_CLIENT_VERSION=" $( $irc_client_path -v) "
IRC_CLIENT="Weechat" IRC_CLIENT="Weechat"
;; ;;
*kvirc*) kvirc)
IRC_CLIENT_VERSION=" $( $irc_client_path -v 2>&1 | gawk '{ IRC_CLIENT_VERSION=" $( $irc_client_path -v 2>&1 | gawk '{
for ( i=2; i<=NF; i++) { for ( i=2; i<=NF; i++) {
if (i==NF) { if (i==NF) {
@ -727,7 +728,7 @@ get_start_client()
}' )" }' )"
IRC_CLIENT="KVIrc" IRC_CLIENT="KVIrc"
;; ;;
*kopete*) kopete)
IRC_CLIENT_VERSION=" $( kopete -v | gawk ' IRC_CLIENT_VERSION=" $( kopete -v | gawk '
/Kopete:/ { /Kopete:/ {
print $2 print $2
@ -735,7 +736,7 @@ get_start_client()
}' )" }' )"
IRC_CLIENT="Kopete" IRC_CLIENT="Kopete"
;; ;;
*perl*|*ksirc*|*dsirc*) perl|ksirc|dsirc)
unset IRC_CLIENT_VERSION unset IRC_CLIENT_VERSION
# KSirc is one of the possibilities now. KSirc is a wrapper around dsirc, a perl client # KSirc is one of the possibilities now. KSirc is a wrapper around dsirc, a perl client
get_cmdline $PPID get_cmdline $PPID
@ -765,7 +766,7 @@ get_start_client()
IRC_CLIENT="Unknown Perl client" IRC_CLIENT="Unknown Perl client"
fi fi
;; ;;
*bash*|*dash*|*sh*) bash|dash|sh)
unset IRC_CLIENT_VERSION unset IRC_CLIENT_VERSION
IRC_CLIENT="Shell wrapper" IRC_CLIENT="Shell wrapper"
;; ;;
@ -1726,7 +1727,7 @@ print_hard_disk_data()
local hdd_data='' partition_data='' a_partition_working='' hdd_model='' a_hdd_working='' local hdd_data='' partition_data='' a_partition_working='' hdd_model='' a_hdd_working=''
local dev_data='' size_data='' hdd_model_2='' hdd_data_2='' usb_data='' local dev_data='' size_data='' hdd_model_2='' hdd_data_2='' usb_data=''
if [[ $VERBOSITY_LEVEL -ge 3 ]];then if [[ $VERBOSITY_LEVEL -ge 3 || $B_SHOW_FULL_HDD == 'true' ]];then
## note: the output part of this should be in the print hdd data function, not here ## note: the output part of this should be in the print hdd data function, not here
get_hard_drive_data_advanced get_hard_drive_data_advanced
for (( i=0; i < ${#A_HDD_DATA[@]} - 1; i++ )) for (( i=0; i < ${#A_HDD_DATA[@]} - 1; i++ ))
@ -1735,7 +1736,7 @@ print_hard_disk_data()
IFS="," IFS=","
a_hdd_working=( ${A_HDD_DATA[i]} ) a_hdd_working=( ${A_HDD_DATA[i]} )
IFS="$ORIGINAL_IFS" IFS="$ORIGINAL_IFS"
if [[ $B_EXTRA_DATA == 'true' ]];then if [[ $B_SHOW_FULL_HDD == 'true' ]];then
if [[ -n ${a_hdd_working[3]} ]];then if [[ -n ${a_hdd_working[3]} ]];then
usb_data="(${a_hdd_working[3]})" usb_data="(${a_hdd_working[3]})"
else else
@ -1745,7 +1746,7 @@ print_hard_disk_data()
size_data="-${a_hdd_working[1]}" size_data="-${a_hdd_working[1]}"
fi fi
# wrap to avoid long lines # wrap to avoid long lines
if [[ $i -gt 1 && $B_EXTRA_DATA == 'true' ]] || [[ $i -gt 3 ]];then if [[ $i -gt 1 && $B_SHOW_FULL_HDD == 'true' ]] || [[ $i -gt 3 ]];then
hdd_model_2="${hdd_model_2}${hdd_model_2+${C1}($(($i+1)))${C2}}$usb_data$dev_data${a_hdd_working[2]}$size_data " hdd_model_2="${hdd_model_2}${hdd_model_2+${C1}($(($i+1)))${C2}}$usb_data$dev_data${a_hdd_working[2]}$size_data "
else else
hdd_model="${hdd_model}${hdd_model+ ${C1}($(($i+1)))${C2}}$usb_data$dev_data${a_hdd_working[2]}$size_data" hdd_model="${hdd_model}${hdd_model+ ${C1}($(($i+1)))${C2}}$usb_data$dev_data${a_hdd_working[2]}$size_data"