From 78649452da0322db49e12e98b827b576e419e743 Mon Sep 17 00:00:00 2001 From: inxi-svn Date: Tue, 26 Apr 2011 17:23:44 +0000 Subject: [PATCH] more features, now can set irc colors for terminal in X too. Don't want to leave fringe cases unhandled after all! --- inxi | 234 +++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 131 insertions(+), 103 deletions(-) diff --git a/inxi b/inxi index 3ec9793..953d009 100755 --- a/inxi +++ b/inxi @@ -1,7 +1,7 @@ #!/bin/bash ######################################################################## #### Script Name: inxi -#### version: 1.4.82-b9 +#### version: 1.4.82-b10 #### Date: April 26 2011 ######################################################################## #### SPECIAL THANKS @@ -120,6 +120,8 @@ #### #### 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) ################################################################################### @@ -201,6 +203,7 @@ A_X_DATA='' # -U and -! testing/advanced update options, as well as removing the -U help menu item B_ALLOW_UPDATE='true' B_COLOR_SCHEME_SET='false' +B_CONSOLE_IRC='false' # triggers full display of cpu flags B_CPU_FLAGS_FULL='false' # test for dbus irc client @@ -310,6 +313,7 @@ DEFAULT_COLOR_SCHEME=2 GLOBAL_COLOR_SCHEME='' IRC_COLOR_SCHEME='' IRC_CONS_COLOR_SCHEME='' +IRC_X_TERM_COLOR_SCHEME='' CONSOLE_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) 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 ## 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; @@ -550,32 +554,33 @@ main() # If no colorscheme was set in the parameter handling routine, then set the default scheme 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 - # The override value only will occur in user config files - 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 - 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 + # This let's user pick their color scheme. For IRC, only shows the color schemes, no interactive + # The override value only will be placed in user config files. /etc/inxi.conf can also override + if [[ $B_RUN_COLOR_SELECTOR == 'true' ]];then + select_default_color_scheme else + # set the default, then override as required + color_scheme=$DEFAULT_COLOR_SCHEME if [[ -n $GLOBAL_COLOR_SCHEME ]];then - set_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 + color_scheme=$GLOBAL_COLOR_SCHEME 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 + 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 @@ -841,7 +846,7 @@ select_default_color_scheme() set_color_scheme "0" 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 " " 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." print_screen_output "After these, there are 3 sets: 1-dark or light backgrounds; 2-light backgrounds; 3-dark backgrounds." @@ -853,82 +858,95 @@ select_default_color_scheme() spacer=' ' fi set_color_scheme $i - 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 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+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 "------------------------------------------------------------------------------" - 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 "96 (virtual-terminal), 97 (irc), 98 (irc-console), 99 (global). Your selection(s) will be stored here: $config_file" - print_screen_output "Global overrides virtual-terminal/console/irc/irc-console. Irc/irc-console/virtual-terminal/console removes 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='IRC_COLOR_SCHEME' - ;; - irc-console) - config_variable='IRC_CONS_COLOR_SCHEME' - ;; - console) - config_variable='CONSOLE_COLOR_SCHEME' - ;; - virtual-terminal) - config_variable='VIRT_TERM_COLOR_SCHEME' - ;; - global) - config_variable='GLOBAL_COLOR_SCHEME' - ;; - esac - set_color_scheme $user_selection - if [[ ! -f $config_file || -z $( grep -s "$config_variable=" $config_file ) ]];then - if [[ ! -d $HOME/.$SCRIPT_NAME ]];then - mkdir $HOME/.$SCRIPT_NAME + 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 plus one of these numbers:" + 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 "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 "------------------------------------------------------------------------------" + read user_selection + if [[ -n $( grep -Es '^([0-9]+)$' <<< "$user_selection" ) && $user_selection -lt $i ]];then + case $COLOR_SELECTION in + irc) + config_variable='IRC_COLOR_SCHEME' + ;; + irc-console) + config_variable='IRC_CONS_COLOR_SCHEME' + ;; + irc-virtual-terminal) + config_variable='IRC_X_TERM_COLOR_SCHEME' + ;; + console) + config_variable='CONSOLE_COLOR_SCHEME' + ;; + virtual-terminal) + config_variable='VIRT_TERM_COLOR_SCHEME' + ;; + global) + config_variable='GLOBAL_COLOR_SCHEME' + ;; + esac + set_color_scheme $user_selection + if [[ ! -f $config_file || -z $( grep -s "$config_variable=" $config_file ) ]];then + if [[ ! -d $HOME/.$SCRIPT_NAME ]];then + mkdir $HOME/.$SCRIPT_NAME + fi + 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 for $COLOR_SELECTION color scheme now..." + sed -i "s/$config_variable=.*/$config_variable=$user_selection/" $config_file fi - 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 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|irc-console|console|virtual-terminal) - sed -i '/GLOBAL_COLOR_SCHEME=/d' $config_file - ;; - global) - 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 - ;; - esac - elif [[ $user_selection == $i ]];then - 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' \ - -e '/IRC_COLOR_SCHEME=/d' -e '/IRC_CONS_COLOR_SCHEME=/d' $config_file - set_color_scheme $DEFAULT_COLOR_SCHEME - 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" - if [[ -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 + # file exists now so we can go on to cleanup + case $COLOR_SELECTION in + irc|irc-console|irc-virtual-terminal|console|virtual-terminal) + sed -i '/GLOBAL_COLOR_SCHEME=/d' $config_file + ;; + global) + sed -i -e '/VIRT_TERM_COLOR_SCHEME=/d' -e '/CONSOLE_COLOR_SCHEME=/d' -e '/IRC_COLOR_SCHEME=/d' \ + -e '/IRC_CONS_COLOR_SCHEME=/d' -e '/IRC_X_TERM_COLOR_SCHEME=/d' $config_file + ;; + esac + elif [[ $user_selection == $i ]];then + 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' \ + -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 + 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" + if [[ -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 + elif [[ $user_selection == $(( $i+2 )) ]];then + set_color_scheme $DEFAULT_COLOR_SCHEME + print_screen_output "Ok, exiting $SCRIPT_NAME now. You can set the colors later." + exit 0 + else + print_screen_output "Error - Invalid Selection. You entered this: $user_selection" + print_screen_output " " + select_default_color_scheme fi - elif [[ $user_selection == $(( $i+2 )) ]];then - set_color_scheme $DEFAULT_COLOR_SCHEME - print_screen_output "Ok, exiting $SCRIPT_NAME now. You can set the colors later." - exit 0 else - print_screen_output "Error - Invalid Selection. You entered this: $user_selection" - print_screen_output "" - select_default_color_scheme + 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 @@ -1251,13 +1269,17 @@ get_parameters() ;; 97) B_RUN_COLOR_SELECTOR='true' - COLOR_SELECTION='irc' + COLOR_SELECTION='irc-virtual-terminal' ;; 96) B_RUN_COLOR_SELECTOR='true' - COLOR_SELECTION='virtual-terminal' + COLOR_SELECTION='irc' ;; 95) + B_RUN_COLOR_SELECTOR='true' + COLOR_SELECTION='virtual-terminal' + ;; + 94) B_RUN_COLOR_SELECTOR='true' COLOR_SELECTION='console' ;; @@ -1457,7 +1479,7 @@ show_options() print_screen_output "$SCRIPT_NAME supports the following options. You can combine them, or list them" print_screen_output "one by one: Examples: $SCRIPT_NAME -v4 -c6 OR $SCRIPT_NAME -dDc 6" - print_screen_output "" + print_screen_output " " print_screen_output "If you start $SCRIPT_NAME with no arguments, it will show the short form." print_screen_output "The following options if used without -d or -v will show just that complete line:" print_screen_output "A,C,D,G,I,N,P,S - you can use these together to show just the lines you want to see." @@ -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 " 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 95 (Terminal - No X); 96 (Virtual Terminal - in X); 97 (IRC);" - print_screen_output " 98 (Irc Terminal - no X); 99 (Global)" + print_screen_output " Supported color selectors: 94 (console, no X); 95 (terminal, X); 96 (irc, X);" + 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 "-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." @@ -1512,7 +1534,7 @@ 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 " added to /etc/sudoers (sudo v. 1.7 or newer): 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 "" + print_screen_output " " print_screen_output "Additional Options:" print_screen_output "-h - this help menu." if [[ $B_ALLOW_UPDATE == 'true' ]];then @@ -1524,7 +1546,7 @@ show_options() print_screen_output "-@ Triggers debugger output. Requires debugging level 1-10 (8-10 - logging)." print_screen_output " 8 - basic logging; 9 - full file/sys info logging; 10 - color logging." if [[ $1 == 'full' ]];then - print_screen_output "" + print_screen_output " " print_screen_output "Developer and Testing Options (Advanced):" print_screen_output "-! 1 - Sets testing flag B_TESTING_1='true' to trigger testing condition 1." print_screen_output "-! 2 - Sets testing flag B_TESTING_2='true' to trigger testing condition 2." @@ -1535,9 +1557,9 @@ show_options() 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 "-! - Triggers an update from whatever server you list." - print_screen_output "" + print_screen_output " " fi - print_screen_output "" + print_screen_output " " } ## print out version information for -V/--version @@ -1549,15 +1571,15 @@ print_version_info() print_screen_output "Version: $SCRIPT_VERSION_NUMBER" print_screen_output "Script Last Modified: $last_modified" print_screen_output "Script Location: $SCRIPT_PATH" - print_screen_output "" + print_screen_output " " print_screen_output "Tested with Irssi, Xchat, Konversation, BitchX, KSirc, ircII," print_screen_output "Gaim/Pidgin, Weechat, KVIrc and Kopete." - print_screen_output "" + print_screen_output " " print_screen_output "This script is a fork of Infobash 3.02, which is:" print_screen_output "Copyright (C) 2005-2007 Michiel de Boer a.k.a. locsmif" print_screen_output "Subsequent changes and modifications (after Infobash 3.02) are:" print_screen_output "Copyright (C) 2008-10 Scott Rogers, Harald Hope, aka trash80 & h2" - print_screen_output "" + print_screen_output " " print_screen_output "This program is free software; you can redistribute it and/or modify" print_screen_output "it under the terms of the GNU General Public License as published by" print_screen_output "the Free Software Foundation; either version 3 of the License, or" @@ -1626,12 +1648,14 @@ get_start_client() print a exit }' )" + B_CONSOLE_IRC='true' IRC_CLIENT="BitchX" ;; finch) IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 { print $2 }' )" + B_CONSOLE_IRC='true' IRC_CLIENT="Finch" ;; gaim) @@ -1644,12 +1668,14 @@ get_start_client() IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 { print $3 }' )" + B_CONSOLE_IRC='true' IRC_CLIENT="ircII" ;; irssi-text|irssi) IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 { print $2 }' )" + B_CONSOLE_IRC='true' IRC_CLIENT="Irssi" ;; konversation) ## konvi < 1.2 (qt4) @@ -1763,6 +1789,7 @@ get_start_client() ;; weechat-curses) IRC_CLIENT_VERSION=" $( $irc_client_path -v ) " + B_CONSOLE_IRC='true' IRC_CLIENT="Weechat" ;; xchat-gnome) @@ -1804,6 +1831,7 @@ get_start_client() ;; esac done + B_CONSOLE_IRC='true' if [[ -z $IRC_CLIENT_VERSION ]];then IRC_CLIENT="Unknown Perl client" fi