1.5.2: new options: -z, triggers output filtering. This is default on for irc client output.

-Z - absolute override, turns off all filtering. This is useful if you are helping someone on irc for example and need to see this 
data.

Fixed a long term bug in the regex that filtered out home name from mount paths in partitions, was greedy, now it just filters out 
only the name and prints the rest of the full path, as it should.

Added twm to desktop support list, that has no --version output so that won't show.
This commit is contained in:
inxi-svn 2011-05-24 20:47:22 +00:00
parent 2b9a312eb3
commit b5ac8e13ad

53
inxi
View file

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
######################################################################## ########################################################################
#### Script Name: inxi #### Script Name: inxi
#### version: 1.5.1 #### version: 1.5.2
#### Date: May 23 2011 #### Date: May 24 2011
######################################################################## ########################################################################
#### SPECIAL THANKS #### SPECIAL THANKS
######################################################################## ########################################################################
@ -174,6 +174,7 @@ COLOR_SCHEME=''
CPU_SLEEP='0.3' CPU_SLEEP='0.3'
DEV_DISK_LABEL='' DEV_DISK_LABEL=''
DEV_DISK_UUID='' DEV_DISK_UUID=''
FILTER_STRING='<filter>'
IRC_CLIENT='' IRC_CLIENT=''
IRC_CLIENT_VERSION='' IRC_CLIENT_VERSION=''
PS_COUNT=5 PS_COUNT=5
@ -220,6 +221,8 @@ B_HANDLE_CORRUPT_DATA='false'
B_LABEL_SET='false' B_LABEL_SET='false'
B_LOG_COLORS='false' B_LOG_COLORS='false'
B_LOG_FULL_DATA='false' B_LOG_FULL_DATA='false'
B_OUTPUT_FILTER='false'
B_OVERRIDE_FILTER='false'
# kde qdbus # kde qdbus
B_QDBUS='false' B_QDBUS='false'
B_ROOT='false' B_ROOT='false'
@ -1469,7 +1472,7 @@ get_parameters()
# the short form only runs if no args output args are used # the short form only runs if no args output args are used
# no need to run through these if there are no args # no need to run through these if there are no args
if [[ -n $1 ]];then if [[ -n $1 ]];then
while getopts Ac:CdDfFGhHiIlnNopPrsSt:uv:Vx%@:${update_flags} opt while getopts Ac:CdDfFGhHiIlnNopPrsSt:uv:VxzZ%@:${update_flags} opt
do do
case $opt in case $opt in
A) B_SHOW_AUDIO='true' A) B_SHOW_AUDIO='true'
@ -1611,6 +1614,10 @@ get_parameters()
;; ;;
x) B_EXTRA_DATA='true' x) B_EXTRA_DATA='true'
;; ;;
z) B_OUTPUT_FILTER='true'
;;
Z) B_OVERRIDE_FILTER='true'
;;
h) show_options h) show_options
exit 0 exit 0
;; ;;
@ -1701,6 +1708,10 @@ get_parameters()
if [[ $use_short == 'true' ]];then if [[ $use_short == 'true' ]];then
B_SHOW_SHORT_OUTPUT='true' B_SHOW_SHORT_OUTPUT='true'
fi fi
# just in case someone insists on using -zZ
if [[ $B_OVERRIDE_FILTER == 'true' ]];then
B_OUTPUT_FILTER='false'
fi
eval $LOGFE eval $LOGFE
} }
@ -1766,6 +1777,8 @@ show_options()
print_screen_output " Shows hdd temp with disk data if you have hddtemp installed, if you are root OR if you have" print_screen_output " Shows hdd temp with disk data if you have hddtemp installed, if you are root OR if you have"
print_screen_output " added to /etc/sudoers (sudo v. 1.7 or newer): <username> ALL = NOPASSWD: /usr/sbin/hddtemp (sample)" print_screen_output " added to /etc/sudoers (sudo v. 1.7 or newer): <username> ALL = NOPASSWD: /usr/sbin/hddtemp (sample)"
print_screen_output " For -t, adds memory use output to cpu (-tx c), and cpu use to memory (-tx m)." print_screen_output " For -t, adds memory use output to cpu (-tx c), and cpu use to memory (-tx m)."
print_screen_output "-z Adds security filters for IP addresses, Mac, and user home directory name. Default on for irc clients."
print_screen_output "-Z Absolute override for output filters. Useful for debugging networking issues in irc for example."
print_screen_output " " print_screen_output " "
print_screen_output "Additional Options:" print_screen_output "Additional Options:"
print_screen_output "-h - this help menu." print_screen_output "-h - this help menu."
@ -1841,6 +1854,9 @@ get_start_client()
unset IRC_CLIENT_VERSION unset IRC_CLIENT_VERSION
B_RUNNING_IN_SHELL='true' B_RUNNING_IN_SHELL='true'
elif [[ -n $PPID && -f /proc/$PPID/exe ]];then elif [[ -n $PPID && -f /proc/$PPID/exe ]];then
if [[ $B_OVERRIDE_FILTER != 'true' ]];then
B_OUTPUT_FILTER='true'
fi
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 )
app_working_name=$( basename $irc_client_path_lower ) app_working_name=$( basename $irc_client_path_lower )
@ -2089,6 +2105,9 @@ get_start_client()
else else
## lets look to see if qt4_konvi is the parent. There is no direct way to tell, so lets infer it. ## lets look to see if qt4_konvi is the parent. There is no direct way to tell, so lets infer it.
## because $PPID does not work with qt4_konvi, the above case does not work ## because $PPID does not work with qt4_konvi, the above case does not work
if [[ $B_OVERRIDE_FILTER != 'true' ]];then
B_OUTPUT_FILTER='true'
fi
b_qt4_konvi=$( is_this_qt4_konvi ) b_qt4_konvi=$( is_this_qt4_konvi )
if [[ $b_qt4_konvi == 'true' ]];then if [[ $b_qt4_konvi == 'true' ]];then
KONVI=3 KONVI=3
@ -2637,7 +2656,7 @@ detect_desktop_environment()
toolkit=$( pkg-config --modversion gtk+-2.0 2>/dev/null ) toolkit=$( pkg-config --modversion gtk+-2.0 2>/dev/null )
fi fi
if [[ -n $toolkit ]];then if [[ -n $toolkit ]];then
version="$version (Gtk: $toolkit)" version="$version (Gtk $toolkit)"
fi fi
fi fi
desktop_environment="Gnome" desktop_environment="Gnome"
@ -2699,7 +2718,7 @@ detect_desktop_environment()
if [[ $B_EXTRA_DATA == 'true' ]];then if [[ $B_EXTRA_DATA == 'true' ]];then
toolkit=$( get_de_version 'xfdesktop' 'Built[[:space:]]with[[:space:]]GTK' '4' ) toolkit=$( get_de_version 'xfdesktop' 'Built[[:space:]]with[[:space:]]GTK' '4' )
if [[ -n $toolkit ]];then if [[ -n $toolkit ]];then
version="$version (Gtk+ $toolkit)" version="$version (Gtk $toolkit)"
fi fi
fi fi
desktop_environment="Xfce" desktop_environment="Xfce"
@ -2712,7 +2731,7 @@ detect_desktop_environment()
if [[ $B_EXTRA_DATA == 'true' ]];then if [[ $B_EXTRA_DATA == 'true' ]];then
toolkit=$( get_de_version 'xfdesktop' 'Built[[:space:]]with[[:space:]]GTK' '4' ) toolkit=$( get_de_version 'xfdesktop' 'Built[[:space:]]with[[:space:]]GTK' '4' )
if [[ -n $toolkit ]];then if [[ -n $toolkit ]];then
version="$version (Gtk+ $toolkit)" version="$version (Gtk $toolkit)"
fi fi
fi fi
desktop_environment="Xfce" desktop_environment="Xfce"
@ -2753,6 +2772,8 @@ detect_desktop_environment()
elif [[ -n $( grep -is 'awesome' <<< "$ps_aux" | grep -v 'grep' ) ]];then elif [[ -n $( grep -is 'awesome' <<< "$ps_aux" | grep -v 'grep' ) ]];then
version=$( get_de_version 'awesome' '^awesome' '2' ) version=$( get_de_version 'awesome' '^awesome' '2' )
desktop_environment='Awesome' desktop_environment='Awesome'
elif [[ -n $( grep -is 'twm' <<< "$ps_aux" | grep -v 'grep' ) ]];then
desktop_environment='TWM' # no --version for this one
fi fi
fi fi
fi fi
@ -5777,10 +5798,10 @@ print_network_advanced_data()
duplex_string="${C1}duplex:${C2} $duplex " duplex_string="${C1}duplex:${C2} $duplex "
fi fi
if [[ -n ${a_network_working[9]} ]];then if [[ -n ${a_network_working[9]} ]];then
if [[ $B_RUNNING_IN_SHELL == 'true' ]];then if [[ $B_OUTPUT_FILTER == 'true' ]];then
mac_id=${a_network_working[9]} mac_id=$FILTER_STRING
else else
mac_id='<irc-filter>' mac_id=${a_network_working[9]}
fi fi
fi fi
network_data="${C1}IF:${C2} $if_id ${C1}state:${C2} $oper_state $speed_string$duplex_string${C1}mac:${C2} $mac_id" network_data="${C1}IF:${C2} $if_id ${C1}state:${C2} $oper_state $speed_string$duplex_string${C1}mac:${C2} $mac_id"
@ -5803,6 +5824,10 @@ print_networking_ip_data()
# first print output for wan ip line. Null is handled in the get function # first print output for wan ip line. Null is handled in the get function
if [[ -z $ip ]];then if [[ -z $ip ]];then
ip='N/A' ip='N/A'
else
if [[ $B_OUTPUT_FILTER == 'true' ]];then
ip=$FILTER_STRING
fi
fi fi
ip_data=$( create_print_line " " "${C1}Wan IP:${C2} $ip" ) ip_data=$( create_print_line " " "${C1}Wan IP:${C2} $ip" )
@ -5816,10 +5841,10 @@ print_networking_ip_data()
if_id='N/A' if_id='N/A'
if_ip='N/A' if_ip='N/A'
if [[ -n ${a_interfaces_working[1]} ]];then if [[ -n ${a_interfaces_working[1]} ]];then
if [[ $B_RUNNING_IN_SHELL == 'true' ]];then if [[ $B_OUTPUT_FILTER == 'true' ]];then
if_ip=${a_interfaces_working[1]} if_ip=$FILTER_STRING
else else
if_ip='<irc-filter>' if_ip=${a_interfaces_working[1]}
fi fi
fi fi
if [[ -n ${a_interfaces_working[0]} ]];then if [[ -n ${a_interfaces_working[0]} ]];then
@ -5918,8 +5943,8 @@ print_partition_data()
full_uuid=" ${C1}uuid:${C2} $part_uuid" full_uuid=" ${C1}uuid:${C2} $part_uuid"
fi fi
fi fi
if [[ $B_RUNNING_IN_SHELL == 'false' ]];then if [[ $B_OUTPUT_FILTER == 'true' ]];then
partitionIdClean=$( sed -r 's|/home/(.*)/(.*)|/home/##/\2|' <<< ${a_partition_working[0]} ) partitionIdClean=$( sed -r "s|/home/([^/]+)/(.*)|/home/$FILTER_STRING/\2|" <<< ${a_partition_working[0]} )
else else
partitionIdClean=${a_partition_working[0]} partitionIdClean=${a_partition_working[0]}
fi fi