diff --git a/inxi b/inxi index 77e9f0a..807d672 100755 --- a/inxi +++ b/inxi @@ -1,8 +1,8 @@ #!/usr/bin/env bash ######################################################################## #### Script Name: inxi -#### Version: 2.1.16 -#### Date: 2014-04-02 +#### Version: 2.1.17 +#### Date: 2014-04-03 #### Patch Number: 00 ######################################################################## #### SPECIAL THANKS @@ -646,48 +646,11 @@ main() if [[ -s $HOME/.$SCRIPT_NAME/$SCRIPT_NAME.conf ]];then source $HOME/.$SCRIPT_NAME/$SCRIPT_NAME.conf fi - ## sometimes tput will trigger an error (mageia) if irc client - if [[ $B_IRC == 'false' ]];then - if type -p tput &>/dev/null;then - TERM_COLUMNS=$(tput cols) - TERM_LINES=$(tput lines) - fi - # double check, just in case it's missing functionality or whatever - if [[ -n ${TERM_COLUMNS##[0-9]*} ]];then - TERM_COLUMNS=80 - TERM_LINES=100 - fi - fi - # Convert to new variable names if set in config files, legacy test - if [[ -n $LINE_MAX_CONSOLE ]];then - COLS_MAX_CONSOLE=$LINE_MAX_CONSOLE - fi - if [[ -n $LINE_MAX_IRC ]];then - COLS_MAX_IRC=$LINE_MAX_IRC - fi - # this lets you set different widths for in or out of display server -# if [[ $B_RUNNING_IN_DISPLAY == 'false' && -n $COLS_MAX_NO_DISPLAY ]];then -# COLS_MAX_CONSOLE=$COLS_MAX_NO_DISPLAY -# fi - # TERM_COLUMNS is set in top globals, using tput cols - # echo tc: $TERM_COLUMNS cmc: $COLS_MAX_CONSOLE - if [[ $TERM_COLUMNS -lt $COLS_MAX_CONSOLE ]];then - COLS_MAX_CONSOLE=$TERM_COLUMNS - fi - # adjust, some terminals will wrap if output cols == term cols - COLS_MAX_CONSOLE=$(( $COLS_MAX_CONSOLE - 2 )) - # echo cmc: $COLS_MAX_CONSOLE - # comes after source for user set stuff - if [[ $B_IRC == 'false' ]];then - COLS_MAX=$COLS_MAX_CONSOLE - else - COLS_MAX=$COLS_MAX_IRC - fi -# echo SCHEME $SCHEME -# echo B_IRC $B_IRC -# echo sep3: $SEP3 - COLS_INNER=$(( $COLS_MAX - $INDENT - 1 )) - # echo cm: $COLS_MAX ci: $COLS_INNER + set_display_width 'live' # can be reset with -y + + # echo SCHEME $SCHEME + # echo B_IRC $B_IRC + # echo sep3: $SEP3 # Check for dependencies BEFORE running ANYTHING else except above functions # Not all distro's have these depends installed by default. Don't want to run # this if the user is requesting to see this information in the first place @@ -908,6 +871,56 @@ initialize_data() eval $LOGFE } +# args: $1 - default OR override default cols max integer count +set_display_width() +{ + local cols_max_override=$1 + + if [[ $cols_max_override == 'live' ]];then + ## sometimes tput will trigger an error (mageia) if irc client + if [[ $B_IRC == 'false' ]];then + if type -p tput &>/dev/null;then + TERM_COLUMNS=$(tput cols) + TERM_LINES=$(tput lines) + fi + # double check, just in case it's missing functionality or whatever + if [[ -z $TERM_COLUMNS || -n ${TERM_COLUMNS//[0-9]/} ]];then + TERM_COLUMNS=80 + TERM_LINES=100 + fi + fi + # Convert to new variable names if set in config files, legacy test + if [[ -n $LINE_MAX_CONSOLE ]];then + COLS_MAX_CONSOLE=$LINE_MAX_CONSOLE + fi + if [[ -n $LINE_MAX_IRC ]];then + COLS_MAX_IRC=$LINE_MAX_IRC + fi + # this lets you set different widths for in or out of display server + # if [[ $B_RUNNING_IN_DISPLAY == 'false' && -n $COLS_MAX_NO_DISPLAY ]];then + # COLS_MAX_CONSOLE=$COLS_MAX_NO_DISPLAY + # fi + # TERM_COLUMNS is set in top globals, using tput cols + # echo tc: $TERM_COLUMNS cmc: $COLS_MAX_CONSOLE + if [[ $TERM_COLUMNS -lt $COLS_MAX_CONSOLE ]];then + COLS_MAX_CONSOLE=$TERM_COLUMNS + fi + # adjust, some terminals will wrap if output cols == term cols + COLS_MAX_CONSOLE=$(( $COLS_MAX_CONSOLE - 2 )) + # echo cmc: $COLS_MAX_CONSOLE + # comes after source for user set stuff + if [[ $B_IRC == 'false' ]];then + COLS_MAX=$COLS_MAX_CONSOLE + else + COLS_MAX=$COLS_MAX_IRC + fi + else + COLS_MAX=$cols_max_override + fi + COLS_INNER=$(( $COLS_MAX - $INDENT - 1 )) + # echo cm: $COLS_MAX ci: $COLS_INNER +} + # arg: $1 - version number: main/patch/date parse_version_data() { @@ -1334,6 +1347,9 @@ error_handler() 20) error_message="The option you selected has been deprecated. $2\nSee the -h (help) menu for currently supported options." ;; + 21) + error_message="Width option requires an integer value of 80 or more.\nYou entered: $2" + ;; *) error_message="error unknown: $@" set -- 99 ;; @@ -1630,6 +1646,7 @@ debug_data_collector() cat /proc/net/arp &> $debug_data_dir/proc-net-arp.txt # bsd data cat /var/run/dmesg.boot &> $debug_data_dir/bsd-var-run-dmesg.boot.txt + echo $COLS_INNER &> $debug_data_dir/cols-inner.txt check_recommends_user_output &> $debug_data_dir/check-recommends-user-output.txt # first download and verify xiin @@ -1766,7 +1783,7 @@ debug_data_collector() echo 'Creating inxi output file now. This can take a few seconds...' echo "Starting $SCRIPT_NAME from: $start_directory" cd $start_directory - $SCRIPT_PATH/$SCRIPT_NAME -FRploudxxx -c 0 -@ 8 > $SCRIPT_DATA_DIR/$debug_data_dir/inxi-FRploudxxx.txt + $SCRIPT_PATH/$SCRIPT_NAME -FRfrploudxxx -c 0 -@ 8 -y 120 > $SCRIPT_DATA_DIR/$debug_data_dir/inxi-FRfrploudxxxy120.txt cp $LOG_FILE $SCRIPT_DATA_DIR/$debug_data_dir if [[ -f $SCRIPT_DATA_DIR/$debug_data_dir.tar.gz ]];then echo "Found and removing previous tar.gz data file: $debug_data_dir.tar.gz" @@ -2158,7 +2175,7 @@ get_parameters() # no need to run through these if there are no args # reserved for future use: -g for extra Graphics; -m for extra Machine; -d for extra Disk elif [[ -n $1 ]];then - while getopts Abc:CdDfFGhHiIlMnNopPrRsSt:uUv:V${weather_flag}xzZ%@:!: opt + while getopts Abc:CdDfFGhHiIlMnNopPrRsSt:uUv:V${weather_flag}xy:zZ%@:!: opt do case $opt in A) B_SHOW_AUDIO='true' @@ -2390,6 +2407,12 @@ get_parameters() B_EXTRA_DATA='true' fi ;; + y) if [[ -z ${OPTARG//[0-9]/} && $OPTARG -ge 80 ]];then + set_display_width "$OPTARG" + else + error_handler 21 "$OPTARG" + fi + ;; z) B_OUTPUT_FILTER='true' ;; Z) B_OVERRIDE_FILTER='true' @@ -2645,6 +2668,7 @@ show_options() if [[ $B_ALLOW_WEATHER == 'true' ]];then print_lines_basic "2" "-w -W" "Location (uses -z/irc filter), weather observation time, wind chill, heat index, dew point (shows extra lines for data where relevant)." fi + print_lines_basic "1" "-y" "Required extra option: integer, 80 or greater. Set the output line width max. Overrides IRC/Terminal settings or actual widths. If used with --help or --recommends, put -y option first. Example:^inxi^-y^130" print_lines_basic "1" "-z" "Security filters for IP/Mac addresses, location, user home directory name. Default on for irc clients." print_lines_basic "1" "-Z" "Absolute override for output filters. Useful for debugging networking issues in irc for example." print_screen_output " " diff --git a/inxi.1 b/inxi.1 index 74d5453..3a30dfa 100755 --- a/inxi.1 +++ b/inxi.1 @@ -1,4 +1,4 @@ -.TH INXI 1 "2014\-03\-14" inxi "inxi manual" +.TH INXI 1 "2014\-04\-03" inxi "inxi manual" .SH NAME inxi \- Command line system information script for console and IRC @@ -265,9 +265,11 @@ Please note, your distribution's maintainer may chose to disable this feature, s Get weather/time for an alternate location. Accepts postal/zip code, city,state pair, or latitude,longitude. Note: city/country/state names must not contain spaces. Replace spaces with '+' sign. No spaces around , (comma). Use only ascii letters in city/state/country names, sorry. -Examples: \-W 95623 OR \-W Boston,MA OR \-W45.5234,\-122.6762 OR \-W new+york,ny -OR \-W bodo,norway. - +Examples: \fB\-W 95623\fR OR \fB\-W Boston,MA\fR OR \fB\-W45.5234,\-122.6762\fR OR \fB\-W new+york,ny\fR +OR \fB\-W bodo,norway\fR. +.TP +.B \-y = 80> +This is an absolute width override which sets the output line width max. Overrides COLS_MAX_IRC/COLS_MAX_CONSOLE globals, or the actual widths of the terminal. If used with \-\-help or \-c 94-99, put \-y option first or the override will be ignored. Example: \fBinxi \-y 130\fR .TP .B \-z Adds security filters for IP addresses, Mac, location (\-w), and user home directory name. Default on for irc clients. diff --git a/inxi.changelog b/inxi.changelog index c50b99f..eff68ba 100755 --- a/inxi.changelog +++ b/inxi.changelog @@ -1,3 +1,27 @@ +===================================================================================== +Version: 2.1.17 +Patch Version: 00 +Script Date: 2014-04-03 +----------------------------------- +Changes: +----------------------------------- +New version, new man page, new tarball. Added -y [integer >= 80] option. This allows for absolute override +of width settings. This overrides any dynamically detected widths, as well as the globals: +COLS_MAX_CONSOLE='115' +COLS_MAX_IRC='105' +Now that inxi widths are largely dynamic in terminal, with a few lingering exceptions, it made sense +to also allow for overrides of this. This is useful in cases where for example you want to output +inxi to text file or for other purposes, or if you just want to test the widths, as in my case. + +-y cannot be used with --recommends, but otherwise it works fine, with --help/-c 94-99 you have to +put -y first in the list of options. + +Example: inxi -v7 -y150 > inxi.txt will ignore the terminal settings and output the lines at basically +max length. + +----------------------------------- +-- Harald Hope - Thu, 03 Apr 2014 10:41:07 -0700 + ===================================================================================== Version: 2.1.16 Patch Version: 00