diff --git a/inxi b/inxi index 21dd0c1..521d966 100755 --- a/inxi +++ b/inxi @@ -1,7 +1,7 @@ #!/bin/bash ######################################################################## #### Script Name: inxi -#### version: 1.4.82-b5 +#### version: 1.4.82-b6 #### Date: April 25 2011 ######################################################################## #### SPECIAL THANKS @@ -306,6 +306,8 @@ DEBUG_BUFFER_INDEX=0 DEFAULT_COLOR_SCHEME=2 # Always leave this blank, this is only going to be set in inxi.conf files, that makes testing # for user changes easier after sourcing the files +DEFAULT_GLOBAL_COLOR_SCHEME='' +DEFAULT_IRC_COLOR_SCHEME='' DEFAULT_TERM_COLOR_SCHEME='' # Default indentation level @@ -552,11 +554,19 @@ main() select_default_color_scheme elif [[ -n $DEFAULT_TERM_COLOR_SCHEME ]];then set_color_scheme $DEFAULT_TERM_COLOR_SCHEME + elif [[ -n $DEFAULT_GLOBAL_COLOR_SCHEME ]];then + set_color_scheme $DEFAULT_GLOBAL_COLOR_SCHEME else set_color_scheme "$DEFAULT_COLOR_SCHEME" fi else - set_color_scheme "$DEFAULT_COLOR_SCHEME" + if [[ -n $DEFAULT_IRC_COLOR_SCHEME ]];then + set_color_scheme $DEFAULT_IRC_COLOR_SCHEME + elif [[ -n $DEFAULT_GLOBAL_COLOR_SCHEME ]];then + set_color_scheme $DEFAULT_GLOBAL_COLOR_SCHEME + else + set_color_scheme "$DEFAULT_COLOR_SCHEME" + fi fi fi @@ -816,16 +826,17 @@ set_color_scheme() select_default_color_scheme() { eval $LOGFS - local spacer=' ' options='' user_selection='' + local spacer=' ' options='' user_selection='' config_variable='' + local config_file="$HOME/.$SCRIPT_NAME/$SCRIPT_NAME.conf" # first make output neutral so it's just plain default for console client set_color_scheme "0" - print_screen_output "Welcome to $SCRIPT_NAME! Please select the default Terminal Client color scheme." + print_screen_output "Welcome to $SCRIPT_NAME! Please select the default $COLOR_SELECTION color scheme." # print_screen_output "You will see this message only one time per user account, unless you set preferences in: /etc/$SCRIPT_NAME.conf" print_screen_output "" - print_screen_output "Because there is no way to know your terminal client's foreground/background colors, you can" + print_screen_output "Because there is no way to know your $COLOR_SELECTION foreground/background colors, you can" print_screen_output "set your color preferences from color scheme option list below. 0 is no colors, 1 neutral gray." print_screen_output "After these, there are 3 sets: 1-dark or light backgrounds; 2-light backgrounds; 3-dark backgrounds." - print_screen_output "Please note that this will set the preferences only for your user account: $(whoami)" + print_screen_output "Please note that this will set the $COLOR_SELECTION preferences only for user: $(whoami)" print_screen_output "------------------------------------------------------------------------------" for (( i=0; i < ${#A_COLOR_SCHEMES[@]}; i++ )) do @@ -839,27 +850,48 @@ select_default_color_scheme() print_screen_output " $i)$spacer Continue, no changes or config file setting." print_screen_output " $(($i+1)))$spacer Exit, use another terminal, or set manually." print_screen_output "------------------------------------------------------------------------------" - print_screen_output "Simply type the number for the color scheme that looks best to your eyes in the terminal client you are" - print_screen_output "using and hit enter. NOTE: You can bring this option list up by starting $SCRIPT_NAME with this option: -c 99" - print_screen_output "Your selection will be stored here: $HOME/.$SCRIPT_NAME/$SCRIPT_NAME.conf" + 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 97 to 99" + print_screen_output "Your selection will be stored here: $config_file" + print_screen_output "Setting global value overrides terminal and irc. irc or terminal remove the global." print_screen_output "------------------------------------------------------------------------------" echo -n "" read user_selection if [[ -n $( grep -Es '^([0-9]+)$' <<< "$user_selection" ) && $user_selection -lt $i ]];then + case $COLOR_SELECTION in + irc) + config_variable='DEFAULT_IRC_COLOR_SCHEME' + ;; + terminal) + config_variable='DEFAULT_TERM_COLOR_SCHEME' + ;; + global) + config_variable='DEFAULT_GLOBAL_COLOR_SCHEME' + ;; + esac set_color_scheme $user_selection - if [[ ! -f $HOME/.$SCRIPT_NAME/$SCRIPT_NAME.conf || -z $( grep -s 'DEFAULT_TERM_COLOR_SCHEME=' $HOME/.$SCRIPT_NAME/$SCRIPT_NAME.conf ) ]];then + if [[ ! -f $config_file || -z $( grep -s "$config_variable=" $config_file ) ]];then if [[ ! -d $HOME/.$SCRIPT_NAME ]];then mkdir $HOME/.$SCRIPT_NAME fi - touch $HOME/.$SCRIPT_NAME/$SCRIPT_NAME.conf - print_screen_output "Creating and updating config file now..." - echo "DEFAULT_TERM_COLOR_SCHEME=$user_selection" >> $HOME/.$SCRIPT_NAME/$SCRIPT_NAME.conf + touch $config_file + print_screen_output "Creating and updating config file for $COLOR_SELECTION color scheme now..." + echo "$config_variable=$user_selection" >> $config_file else - print_screen_output "Updating config file now..." - sed -i "s/DEFAULT_TERM_COLOR_SCHEME=.*/DEFAULT_TERM_COLOR_SCHEME=$user_selection/" $HOME/.$SCRIPT_NAME/$SCRIPT_NAME.conf + print_screen_output "Updating config file for $COLOR_SELECTION color scheme now..." + sed -i "s/$config_variable=.*/$config_variable=$user_selection/" $config_file fi + # file exists now so we can go on to cleanup + case $COLOR_SELECTION in + irc|terminal) + sed -i '/DEFAULT_GLOBAL_COLOR_SCHEME=/d' $config_file + ;; + global) + sed -i -e '/DEFAULT_TERM_COLOR_SCHEME=/d' -e '/DEFAULT_IRC_COLOR_SCHEME/d' $config_file + ;; + esac elif [[ $user_selection == $i ]];then - print_screen_output "Ok, continuing $SCRIPT_NAME using defaults. You can set the colors anytime by starting with: -c 99" + print_screen_output "Ok, continuing $SCRIPT_NAME using defaults. You can set the colors anytime by starting with: -c 97, 98, or 99" if [[ -n $DEFAULT_TERM_COLOR_SCHEME ]];then set_color_scheme $DEFAULT_TERM_COLOR_SCHEME else @@ -1184,16 +1216,28 @@ get_parameters() use_short='false' ;; c) if [[ -n $( grep -E '^[0-9][0-9]?$' <<< $OPTARG ) ]];then - if [[ $OPTARG == '99' ]];then - B_RUN_COLOR_SELECTOR='true' - else - B_COLOR_SCHEME_SET='true' - ## note: not sure about this, you'd think user values should be overridden, but - ## we'll leave this for now - if [[ -z $COLOR_SCHEME ]];then - set_color_scheme "$OPTARG" - fi - fi + case $OPTARG in + 99) + B_RUN_COLOR_SELECTOR='true' + COLOR_SELECTION='terminal' + ;; + 98) + B_RUN_COLOR_SELECTOR='true' + COLOR_SELECTION='irc' + ;; + 97) + B_RUN_COLOR_SELECTOR='true' + COLOR_SELECTION='global' + ;; + *) + B_COLOR_SCHEME_SET='true' + ## note: not sure about this, you'd think user values should be overridden, but + ## we'll leave this for now + if [[ -z $COLOR_SCHEME ]];then + set_color_scheme "$OPTARG" + fi + ;; + esac else error_handler 3 "$OPTARG" fi @@ -1390,8 +1434,10 @@ show_options() print_screen_output "- - - - - - - - - - - - - - - - - - - - - - - - - - - - -" print_screen_output "Output Control Options:" print_screen_output "-A Show Audio/sound card information." - print_screen_output "-c Available color schemes. Scheme number is required. Note: -c 99 will start the color selector in terminal." - print_screen_output " Supported schemes: 0-$color_scheme_count Example: $SCRIPT_NAME -c 11" + 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 " Supported color schemes: 0-$color_scheme_count Example: $SCRIPT_NAME -c 11" + print_screen_output " Supported color selectors: -c 97 global colors; -c 98 IRC colors; -c 99 Terminal colors" 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 Show full hard Disk info, not only model, ie: /dev/sda ST380817AS 80.0GB."