more features, now can set irc colors for terminal in X too. Don't want to leave fringe cases unhandled after all!

This commit is contained in:
inxi-svn 2011-04-26 17:23:44 +00:00
parent e7acb4bf87
commit 78649452da

94
inxi
View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
######################################################################## ########################################################################
#### Script Name: inxi #### Script Name: inxi
#### version: 1.4.82-b9 #### version: 1.4.82-b10
#### Date: April 26 2011 #### Date: April 26 2011
######################################################################## ########################################################################
#### SPECIAL THANKS #### SPECIAL THANKS
@ -120,6 +120,8 @@
#### ####
#### As with all 'rules' there are acceptions, these are noted where used. #### As with all 'rules' there are acceptions, these are noted where used.
#### ####
#### print_screen_output " " # requires space, not null, to avoid error in for example in irssi
####
################################################################################### ###################################################################################
#### KDE Konversation information. Moving from dcop(qt3/KDE3) to dbus(qt4/KDE4) #### KDE Konversation information. Moving from dcop(qt3/KDE3) to dbus(qt4/KDE4)
################################################################################### ###################################################################################
@ -201,6 +203,7 @@ A_X_DATA=''
# -U and -! testing/advanced update options, as well as removing the -U help menu item # -U and -! testing/advanced update options, as well as removing the -U help menu item
B_ALLOW_UPDATE='true' B_ALLOW_UPDATE='true'
B_COLOR_SCHEME_SET='false' B_COLOR_SCHEME_SET='false'
B_CONSOLE_IRC='false'
# triggers full display of cpu flags # triggers full display of cpu flags
B_CPU_FLAGS_FULL='false' B_CPU_FLAGS_FULL='false'
# test for dbus irc client # test for dbus irc client
@ -310,6 +313,7 @@ DEFAULT_COLOR_SCHEME=2
GLOBAL_COLOR_SCHEME='' GLOBAL_COLOR_SCHEME=''
IRC_COLOR_SCHEME='' IRC_COLOR_SCHEME=''
IRC_CONS_COLOR_SCHEME='' IRC_CONS_COLOR_SCHEME=''
IRC_X_TERM_COLOR_SCHEME=''
CONSOLE_COLOR_SCHEME='' CONSOLE_COLOR_SCHEME=''
VIRT_TERM_COLOR_SCHEME='' VIRT_TERM_COLOR_SCHEME=''
@ -387,7 +391,7 @@ IRC_COLORS=" $IRC_COLORS \x0312 \x0302 \x0313 \x0306 \x0311 \x0310 \x030
#ANSI_COLORS=($ANSI_COLORS); IRC_COLORS=($IRC_COLORS) #ANSI_COLORS=($ANSI_COLORS); IRC_COLORS=($IRC_COLORS)
A_COLORS_AVAILABLE=( DGREY BLACK RED DRED GREEN DGREEN YELLOW DYELLOW BLUE DBLUE MAGENTA DMAGENTA CYAN DCYAN WHITE GREY NORMAL ) A_COLORS_AVAILABLE=( DGREY BLACK RED DRED GREEN DGREEN YELLOW DYELLOW BLUE DBLUE MAGENTA DMAGENTA CYAN DCYAN WHITE GREY NORMAL )
# A_COLOR_SCHEMES=( EMPTY,EMPTY,EMPTY NORMAL,NORMAL,NORMAL BLUE,NORMAL,NORMAL GREEN,YELLOW,NORMAL DYELLOW,NORMAL,NORMAL CYAN,BLUE,NORMAL RED,NORMAL,NORMAL GREEN,NORMAL,NORMAL YELLOW,NORMAL,NORMAL GREEN,DGREEN,NORMAL BLUE,RED,NORMAL BLUE,NORMAL,RED YELLOW,WHITE,GREEN BLUE,NORMAL,GREEN DCYAN,NORMAL,DMAGENTA )
# See above for notes on EMPTY # See above for notes on EMPTY
## note: group 1: 0, 1 are null/normal ## note: group 1: 0, 1 are null/normal
## Following: group 2: generic, light/dark or dark/light; group 3: dark on light; group 4 light on dark; ## Following: group 2: generic, light/dark or dark/light; group 3: dark on light; group 4 light on dark;
@ -550,32 +554,33 @@ main()
# If no colorscheme was set in the parameter handling routine, then set the default scheme # If no colorscheme was set in the parameter handling routine, then set the default scheme
if [[ $B_COLOR_SCHEME_SET != 'true' ]];then if [[ $B_COLOR_SCHEME_SET != 'true' ]];then
# This will only trigger on first run out of irc cases, let's user pick their color scheme # This let's user pick their color scheme. For IRC, only shows the color schemes, no interactive
# The override value only will occur in user config files # The override value only will be placed in user config files. /etc/inxi.conf can also override
if [[ $B_RUNNING_IN_SHELL == 'true' ]];then
# note, leaving this iff as a first run default for now, too many possible glitches could happen
# if [[ -z $CONSOLE_COLOR_SCHEME || $B_RUN_COLOR_SELECTOR == 'true' ]];then
if [[ $B_RUN_COLOR_SELECTOR == 'true' ]];then if [[ $B_RUN_COLOR_SELECTOR == 'true' ]];then
select_default_color_scheme select_default_color_scheme
elif [[ -n $GLOBAL_COLOR_SCHEME ]];then
set_color_scheme $GLOBAL_COLOR_SCHEME
elif [[ -n $CONSOLE_COLOR_SCHEME && -z $DISPLAY ]];then
set_color_scheme $CONSOLE_COLOR_SCHEME
elif [[ -n $VIRT_TERM_COLOR_SCHEME ]];then
set_color_scheme $VIRT_TERM_COLOR_SCHEME
else
set_color_scheme "$DEFAULT_COLOR_SCHEME"
fi
else else
# set the default, then override as required
color_scheme=$DEFAULT_COLOR_SCHEME
if [[ -n $GLOBAL_COLOR_SCHEME ]];then if [[ -n $GLOBAL_COLOR_SCHEME ]];then
set_color_scheme $GLOBAL_COLOR_SCHEME color_scheme=$GLOBAL_COLOR_SCHEME
elif [[ -n $IRC_CONS_COLOR_SCHEME && -z $DISPLAY ]];then
set_color_scheme $IRC_CONS_COLOR_SCHEME
elif [[ -n $IRC_COLOR_SCHEME ]];then
set_color_scheme $IRC_COLOR_SCHEME
else else
set_color_scheme "$DEFAULT_COLOR_SCHEME" if [[ $B_RUNNING_IN_SHELL == 'true' ]];then
if [[ -n $CONSOLE_COLOR_SCHEME && -z $DISPLAY ]];then
color_scheme=$CONSOLE_COLOR_SCHEME
elif [[ -n $VIRT_TERM_COLOR_SCHEME ]];then
color_scheme=$VIRT_TERM_COLOR_SCHEME
fi fi
else
if [[ -n $IRC_X_TERM_COLOR_SCHEME && $B_CONSOLE_IRC == 'true' && -n $DISPLAY ]];then
color_scheme=$IRC_X_TERM_COLOR_SCHEME
elif [[ -n $IRC_CONS_COLOR_SCHEME && -z $DISPLAY ]];then
color_scheme=$IRC_CONS_COLOR_SCHEME
elif [[ -n $IRC_COLOR_SCHEME ]];then
color_scheme=$IRC_COLOR_SCHEME
fi
fi
fi
set_color_scheme $color_scheme
fi fi
fi fi
@ -856,16 +861,19 @@ select_default_color_scheme()
print_screen_output " $i)$spacer${C1}Card:${C2} nVidia G86 [GeForce 8400 GS] ${C1}X.Org${C2} 1.7.7" print_screen_output " $i)$spacer${C1}Card:${C2} nVidia G86 [GeForce 8400 GS] ${C1}X.Org${C2} 1.7.7"
done done
set_color_scheme 0 set_color_scheme 0
echo -n ""
if [[ $B_RUNNING_IN_SHELL == 'true' ]];then
print_screen_output " $i)$spacer Remove all color settings. Restore $SCRIPT_NAME default." print_screen_output " $i)$spacer Remove all color settings. Restore $SCRIPT_NAME default."
print_screen_output " $(($i+1)))$spacer Continue, no changes or config file setting." print_screen_output " $(($i+1)))$spacer Continue, no changes or config file setting."
print_screen_output " $(($i+2)))$spacer Exit, use another terminal, or set manually." print_screen_output " $(($i+2)))$spacer Exit, use another terminal, or set manually."
print_screen_output "------------------------------------------------------------------------------" print_screen_output "------------------------------------------------------------------------------"
print_screen_output "Simply type the number for the color scheme that looks best to your eyes for your $COLOR_SELECTION settings" print_screen_output "Simply type the number for the color scheme that looks best to your eyes for your $COLOR_SELECTION settings"
print_screen_output "and hit ENTER. NOTE: You can bring this option list up by starting $SCRIPT_NAME with option: -c 95 (console)," print_screen_output "and hit ENTER. NOTE: You can bring this option list up by starting $SCRIPT_NAME with option: -c plus one of these numbers:"
print_screen_output "96 (virtual-terminal), 97 (irc), 98 (irc-console), 99 (global). Your selection(s) will be stored here: $config_file" print_screen_output "94 (console, no X); 95 (terminal, X); 96 (irc, X); 97 (irc, X, in terminal); 98 (irc, no X); 99 (global)."
print_screen_output "Global overrides virtual-terminal/console/irc/irc-console. Irc/irc-console/virtual-terminal/console removes global." print_screen_output "Your selection(s) will be stored here: $config_file"
print_screen_output "Global overrides all individual color schemes. Individual schemes remove the global setting."
print_screen_output "------------------------------------------------------------------------------" print_screen_output "------------------------------------------------------------------------------"
echo -n ""
read user_selection read user_selection
if [[ -n $( grep -Es '^([0-9]+)$' <<< "$user_selection" ) && $user_selection -lt $i ]];then if [[ -n $( grep -Es '^([0-9]+)$' <<< "$user_selection" ) && $user_selection -lt $i ]];then
case $COLOR_SELECTION in case $COLOR_SELECTION in
@ -875,6 +883,9 @@ select_default_color_scheme()
irc-console) irc-console)
config_variable='IRC_CONS_COLOR_SCHEME' config_variable='IRC_CONS_COLOR_SCHEME'
;; ;;
irc-virtual-terminal)
config_variable='IRC_X_TERM_COLOR_SCHEME'
;;
console) console)
config_variable='CONSOLE_COLOR_SCHEME' config_variable='CONSOLE_COLOR_SCHEME'
;; ;;
@ -899,18 +910,18 @@ select_default_color_scheme()
fi fi
# file exists now so we can go on to cleanup # file exists now so we can go on to cleanup
case $COLOR_SELECTION in case $COLOR_SELECTION in
irc|irc-console|console|virtual-terminal) irc|irc-console|irc-virtual-terminal|console|virtual-terminal)
sed -i '/GLOBAL_COLOR_SCHEME=/d' $config_file sed -i '/GLOBAL_COLOR_SCHEME=/d' $config_file
;; ;;
global) global)
sed -i -e '/VIRT_TERM_COLOR_SCHEME=/d' -e '/CONSOLE_COLOR_SCHEME=/d' -e '/IRC_COLOR_SCHEME=/d' \ sed -i -e '/VIRT_TERM_COLOR_SCHEME=/d' -e '/CONSOLE_COLOR_SCHEME=/d' -e '/IRC_COLOR_SCHEME=/d' \
-e '/IRC_CONS_COLOR_SCHEME=/d' $config_file -e '/IRC_CONS_COLOR_SCHEME=/d' -e '/IRC_X_TERM_COLOR_SCHEME=/d' $config_file
;; ;;
esac esac
elif [[ $user_selection == $i ]];then elif [[ $user_selection == $i ]];then
print_screen_output "Removing all color settings from config file now..." print_screen_output "Removing all color settings from config file now..."
sed -i -e '/VIRT_TERM_COLOR_SCHEME=/d' -e '/GLOBAL_COLOR_SCHEME=/d' -e '/CONSOLE_COLOR_SCHEME=/d' \ sed -i -e '/VIRT_TERM_COLOR_SCHEME=/d' -e '/GLOBAL_COLOR_SCHEME=/d' -e '/CONSOLE_COLOR_SCHEME=/d' \
-e '/IRC_COLOR_SCHEME=/d' -e '/IRC_CONS_COLOR_SCHEME=/d' $config_file -e '/IRC_COLOR_SCHEME=/d' -e '/IRC_CONS_COLOR_SCHEME=/d' -e '/IRC_X_TERM_COLOR_SCHEME=/d' $config_file
set_color_scheme $DEFAULT_COLOR_SCHEME set_color_scheme $DEFAULT_COLOR_SCHEME
elif [[ $user_selection == $(( $i+1 )) ]];then elif [[ $user_selection == $(( $i+1 )) ]];then
print_screen_output "Ok, continuing $SCRIPT_NAME unchanged. You can set the colors anytime by starting with: -c 95 to 99" print_screen_output "Ok, continuing $SCRIPT_NAME unchanged. You can set the colors anytime by starting with: -c 95 to 99"
@ -930,6 +941,13 @@ select_default_color_scheme()
print_screen_output " " print_screen_output " "
select_default_color_scheme select_default_color_scheme
fi fi
else
print_screen_output "------------------------------------------------------------------------------"
print_screen_output "After finding the scheme number you like, simply run this again in a terminal to set the configuration"
print_screen_output "data file for your irc client. You can set color schemes for the following: start inxi with -c plus:"
print_screen_output "96 (Gui IRC, in X); 97 (terminal irc client, in X); 98 (console irc, no X) - like: $SCRIPT_NAME -c 97"
exit 0
fi
eval $LOGFE eval $LOGFE
} }
@ -1251,13 +1269,17 @@ get_parameters()
;; ;;
97) 97)
B_RUN_COLOR_SELECTOR='true' B_RUN_COLOR_SELECTOR='true'
COLOR_SELECTION='irc' COLOR_SELECTION='irc-virtual-terminal'
;; ;;
96) 96)
B_RUN_COLOR_SELECTOR='true' B_RUN_COLOR_SELECTOR='true'
COLOR_SELECTION='virtual-terminal' COLOR_SELECTION='irc'
;; ;;
95) 95)
B_RUN_COLOR_SELECTOR='true'
COLOR_SELECTION='virtual-terminal'
;;
94)
B_RUN_COLOR_SELECTOR='true' B_RUN_COLOR_SELECTOR='true'
COLOR_SELECTION='console' COLOR_SELECTION='console'
;; ;;
@ -1469,8 +1491,8 @@ show_options()
print_screen_output "-c Available color schemes. Scheme number is required. Color selectors run a color selector option" print_screen_output "-c Available color schemes. Scheme number is required. Color selectors run a color selector option"
print_screen_output " prior to $SCRIPT_NAME starting which lets you set the config file value for the selection." print_screen_output " prior to $SCRIPT_NAME starting which lets you set the config file value for the selection."
print_screen_output " Supported color schemes: 0-$color_scheme_count Example: $SCRIPT_NAME -c 11" print_screen_output " Supported color schemes: 0-$color_scheme_count Example: $SCRIPT_NAME -c 11"
print_screen_output " Supported color selectors: -c 95 (Terminal - No X); 96 (Virtual Terminal - in X); 97 (IRC);" print_screen_output " Supported color selectors: 94 (console, no X); 95 (terminal, X); 96 (irc, X);"
print_screen_output " 98 (Irc Terminal - no X); 99 (Global)" print_screen_output " 97 (irc, X, in terminal); 98 (irc, no X); 99 (global)."
print_screen_output "-C Show full CPU output, including per CPU clockspeed." print_screen_output "-C Show full CPU output, including per CPU clockspeed."
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 "-D Show full hard Disk info, not only model, ie: /dev/sda ST380817AS 80.0GB." print_screen_output "-D Show full hard Disk info, not only model, ie: /dev/sda ST380817AS 80.0GB."
@ -1626,12 +1648,14 @@ get_start_client()
print a print a
exit exit
}' )" }' )"
B_CONSOLE_IRC='true'
IRC_CLIENT="BitchX" IRC_CLIENT="BitchX"
;; ;;
finch) finch)
IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 { IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 {
print $2 print $2
}' )" }' )"
B_CONSOLE_IRC='true'
IRC_CLIENT="Finch" IRC_CLIENT="Finch"
;; ;;
gaim) gaim)
@ -1644,12 +1668,14 @@ get_start_client()
IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 { IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 {
print $3 print $3
}' )" }' )"
B_CONSOLE_IRC='true'
IRC_CLIENT="ircII" IRC_CLIENT="ircII"
;; ;;
irssi-text|irssi) irssi-text|irssi)
IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 { IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 {
print $2 print $2
}' )" }' )"
B_CONSOLE_IRC='true'
IRC_CLIENT="Irssi" IRC_CLIENT="Irssi"
;; ;;
konversation) ## konvi < 1.2 (qt4) konversation) ## konvi < 1.2 (qt4)
@ -1763,6 +1789,7 @@ get_start_client()
;; ;;
weechat-curses) weechat-curses)
IRC_CLIENT_VERSION=" $( $irc_client_path -v ) " IRC_CLIENT_VERSION=" $( $irc_client_path -v ) "
B_CONSOLE_IRC='true'
IRC_CLIENT="Weechat" IRC_CLIENT="Weechat"
;; ;;
xchat-gnome) xchat-gnome)
@ -1804,6 +1831,7 @@ get_start_client()
;; ;;
esac esac
done done
B_CONSOLE_IRC='true'
if [[ -z $IRC_CLIENT_VERSION ]];then if [[ -z $IRC_CLIENT_VERSION ]];then
IRC_CLIENT="Unknown Perl client" IRC_CLIENT="Unknown Perl client"
fi fi