New tarball, version, man page. Improved remote weather, now it uses -W, and deprecated -! location=..

That was too hard to type and too hard to remember. Also do more dyanamic reordering of weather
output, depending on how much data is present, and how many x options are used.

Added error handling for generic deprecated options, and for options that do not have the correct
syntax for OPTARG, like with -W.

This should about do it for the weather option for now unless I missed something somewhere.
This commit is contained in:
inxi-svn 2013-05-26 03:19:38 +00:00
parent c27514aa58
commit c6905ed8e8
3 changed files with 95 additions and 46 deletions

86
inxi
View file

@ -1,8 +1,8 @@
#!/usr/bin/env bash
########################################################################
#### Script Name: inxi
#### Version: 1.9.6
#### Date: May 19 2013
#### Version: 1.9.7
#### Date: May 25 2013
#### Patch Number: 00
########################################################################
#### SPECIAL THANKS
@ -1207,7 +1207,7 @@ select_default_color_scheme()
#### -------------------------------------------------------------------
# Error handling
# args: $1 - error number; $2 - optional, extra information
# args: $1 - error number; $2 - optional, extra information; $3 - optional extra info
error_handler()
{
eval $LOGFS
@ -1255,6 +1255,12 @@ error_handler()
17)
error_message="All $SCRIPT_NAME self updater features have been disabled by the distribution\npackage maintainer. This includes the option you used: $2"
;;
18)
error_message="The argument you provided for $2 does not have supported syntax.\nPlease use the following formatting:\n$3"
;;
19)
error_message="The option $2 has been deprecated. Please use $3 instead.\nSee -h for instructions and syntax."
;;
20)
error_message="The option you selected has been deprecated. $2\nSee the -h (help) menu for currently supported options."
;;
@ -2004,12 +2010,13 @@ remove_erroneous_chars()
get_parameters()
{
eval $LOGFS
local opt='' wget_test='' debug_data_type='' weather_flag='w'
local opt='' wget_test='' debug_data_type='' weather_flag='wW:'
local use_short='true' # this is needed to trigger short output, every v/d/F/line trigger sets this false
# if distro maintainers don't want the weather feature disable it
if [[ $B_ALLOW_WEATHER == 'false' ]];then
weather_flag=''
fi
if [[ $1 == '--version' ]];then
print_version_info
@ -2239,6 +2246,14 @@ get_parameters()
w) B_SHOW_WEATHER=true
use_short='false'
;;
W) ALTERNATE_WEATHER_LOCATION=$( sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' <<< $OPTARG )
if [[ -n $( grep -Esi '([^,]+,.+|[0-9-]+)' <<< $ALTERNATE_WEATHER_LOCATION ) ]];then
B_SHOW_WEATHER=true
use_short='false'
else
error_handler 18 "-$opt: '$OPTARG'" "city,state OR latitude,longitude OR postal/zip code."
fi
;;
# this will trigger either with x, xx, xxx or with Fx but not with xF
x) if [[ $B_EXTRA_EXTRA_DATA == 'true' ]];then
B_EXTRA_EXTRA_EXTRA_DATA='true'
@ -2359,7 +2374,7 @@ get_parameters()
;;
# for weather function, allows user to set an alternate weather location
location=*)
ALTERNATE_WEATHER_LOCATION=$( sed 's/location=//' <<< $OPTARG )
error_handler 19 "-$opt location=" "-W"
;;
*) error_handler 11 "$OPTARG"
;;
@ -2477,8 +2492,11 @@ show_options()
print_screen_output " 7 - Network IP data (-i); triggers -xxx."
# if distro maintainers don't want the weather feature disable it
if [[ $B_ALLOW_WEATHER == 'true' ]];then
print_screen_output "-w Local weather data/time. To check an alternate location, see: -! location=<location>."
print_screen_output " For extra data options see -x, -xx, and -xxx."
print_screen_output "-w Local weather data/time. To check an alternate location, see: -W <location>."
print_screen_output " For extra weather data options see -x, -xx, and -xxx."
print_screen_output "-W <location> - <location> supported options: postal code; city,[state/country]; latitude,longitude"
print_screen_output " Only use if you want the weather somewhere other than the machine running $SCRIPT_NAME."
print_screen_output " Use only ascii characters, replace spaces in city/state/country names with +: new+york,ny"
fi
print_screen_output "-x Adds the following extra data (only works with verbose or line output, not short form): "
print_screen_output " -C - Bogomips on Cpu;"
@ -2498,7 +2516,7 @@ show_options()
print_screen_output " -S - Desktop toolkit if avaliable (GNOME/XFCE/KDE only); Kernel gcc version"
print_screen_output " -t - Memory use output to cpu (-xt c), and cpu use to memory (-xt m)."
if [[ $B_ALLOW_WEATHER == 'true' ]];then
print_screen_output " -w - Wind speed and time zone."
print_screen_output " -w/-W - Wind speed and time zone (-w only)."
fi
print_screen_output "-xx Show extra, extra data (only works with verbose or line output, not short form): "
print_screen_output " -A - Chip vendor:product ID for each audio device."
@ -2513,13 +2531,13 @@ show_options()
print_screen_output " Resync line, shows progress bar."
print_screen_output " -S - Display manager (dm) in desktop output, if in X (like kdm, gdm3, lightdm)."
if [[ $B_ALLOW_WEATHER == 'true' ]];then
print_screen_output " -w - Humidity, barometric pressure."
print_screen_output " -w/-W - Humidity, barometric pressure."
fi
print_screen_output " -xx -@ <11-14> - Automatically uploads debugger data tar.gz file to ftp.techpatterns.com."
print_screen_output "-xxx Show extra, extra, extra data (only works with verbose or line output, not short form): "
print_screen_output " -S - Panel/shell information in desktop output, if in X (like gnome-shell, cinnamon, mate-panel)."
if [[ $B_ALLOW_WEATHER == 'true' ]];then
print_screen_output " -w - Location (uses -z/irc filter), weather observation time, wind chill, heat index,"
print_screen_output " -w/-W - Location (uses -z/irc filter), weather observation time, wind chill, heat index,"
print_screen_output " dew point (shows extra lines for data where relevant)."
fi
print_screen_output "-z Security filters for IP/Mac addresses, location, user home directory name. Default on for irc clients."
@ -2554,11 +2572,7 @@ show_options()
print_screen_output "Advanced Options:"
print_screen_output "-! 31 Turns off hostname in output. Useful if showing output from servers etc."
print_screen_output "-! 32 Turns on hostname in output. Overrides global B_SHOW_HOST='false'"
if [[ $B_ALLOW_WEATHER == 'true' ]];then
print_screen_output "-! location=<location> - <location> Supported: postal code; city,[state/country]; latitude,longitude"
print_screen_output " Only use if you want the weather somewhere other than the machine running $SCRIPT_NAME."
print_screen_output " Must be used with -w. Only ascii, replace spaces in city/state/country names with +: new+york,ny"
fi
if [[ $1 == 'full' ]];then
print_screen_output " "
print_screen_output "Developer and Testing Options (Advanced):"
@ -10689,7 +10703,7 @@ print_weather_data()
local weather_data='' location_string='' local_time='' time_string='' pressure=''
local a_location='' a_weather='' weather_string='' weather='' temp='' winds='' humidity=''
local time_zone='' observation_time='' city='' state='' country='' altitude=''
local heat_index="" wind_chill='' dewpoint=''
local heat_index="" wind_chill='' dewpoint='' xxx_humidity=''
local openP='(' closeP=')'
if [[ $B_RUNNING_IN_SHELL == 'false' ]];then
@ -10745,7 +10759,7 @@ print_weather_data()
if [[ $B_EXTRA_DATA == 'true' && -n ${a_location[8]} ]];then
time_zone=" (${a_location[8]})"
fi
time_string="$pressure${C1}Time$SEP3${C2}$local_time$time_zone"
time_string="${C1}Time$SEP3${C2}$local_time$time_zone"
if [[ $B_EXTRA_DATA != 'true' ]];then
weather_data="$weather_string $time_string"
@ -10765,18 +10779,8 @@ print_weather_data()
if [[ -n ${a_weather[7]} ]];then
dew_point="${C1}Dew Point$SEP3${C2} ${a_weather[7]} "
fi
# these were blank in my tests
if [[ -n "$heat_index$wind_chill$dew_point" ]];then
weather_data=$( create_print_line " " "$heat_index$wind_chill$dew_point" )
print_screen_output "$weather_data"
fi
fi
weather_data="$time_string"
weather_data=$( create_print_line " " "$weather_data" )
print_screen_output "$weather_data"
if [[ $B_EXTRA_EXTRA_EXTRA_DATA == 'true' ]];then
if [[ -n ${a_weather[0]} ]];then
observation_time="${C1}Observation Time$SEP3${C2} ${a_weather[0]} "
observation_time=" ${C1}Observation Time$SEP3${C2} ${a_weather[0]} "
fi
if [[ $B_OUTPUT_FILTER != 'true' ]];then
if [[ -n ${a_location[0]} ]];then
@ -10792,9 +10796,33 @@ print_weather_data()
altitude=" ${C1}Altitude$SEP3${C2} ${a_weather[10]}"
fi
location_string="${C1}Location$SEP3${C2}$city$state$country$altitude "
else
location_string=$time_string$observation_time
time_string=''
observation_time=''
fi
weather_data=$( create_print_line " " "$location_string$observation_time" )
# the last three are oftenblank
if [[ -z "$heat_index$wind_chill$dew_point" ]];then
weather_data=$( create_print_line " " "$pressure$location_string" )
print_screen_output "$weather_data"
else
weather_data=$( create_print_line " " "$pressure$heat_index$wind_chill$dew_point" )
print_screen_output "$weather_data"
if [[ $B_OUTPUT_FILTER != 'true' ]];then
weather_data=$( create_print_line " " "$location_string" )
print_screen_output "$weather_data"
fi
fi
if [[ -n $time_string$observation_time ]];then
weather_data=$( create_print_line " " "$time_string$observation_time" )
print_screen_output "$weather_data"
fi
else
if [[ -n $pressure$time_string ]];then
weather_data="$pressure$time_string"
weather_data=$( create_print_line " " "$weather_data" )
print_screen_output "$weather_data"
fi
fi
fi
else

33
inxi.1
View file

@ -1,4 +1,4 @@
.TH INXI 1 "2013\-05\-18" inxi "inxi manual"
.TH INXI 1 "2013\-05\-25" inxi "inxi manual"
.SH NAME
inxi \- Command line system information script for console and IRC
@ -251,8 +251,16 @@ triggers \fB\-xx\fR extra data option.
.TP
.B \-w
Adds weather line. Note, this depends on an unreliable api so it may not always be working in the future.
To get weather for an alternate location, use also the \-! location=<location_string>. See also \-x, \-xx, \-xxx option.
Please note, your distribution's maintainer may chose to disable this feature, so if \-w doesn't work, that's why.
To get weather for an alternate location, use \-W <location_string>. See also \-x, \-xx, \-xxx option.
Please note, your distribution's maintainer may chose to disable this feature, so if \-w or \-W don't work, that's why.
.TP
.B \-W <location_string>
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.
.TP
.B \-z
Adds security filters for IP addresses, Mac, location (\-w), and user home directory name. Default on for irc clients.
@ -327,8 +335,8 @@ The following shows which lines / items get extra information with each extra da
.B \-x \-t
\- Adds memory use output to cpu (\fB\-xt c\fR), and cpu use to memory (\fB\-xt m\fR).
.TP
.B \-x \-w
\- Adds wind speed and time zone, and makes output go to two lines.
.B \-x \-w / \-W
\- Adds wind speed and time zone (\-w only), and makes output go to two lines.
.TP
.B \-xx \-A
\- Adds vendor:product ID of each Audio device.
@ -360,7 +368,7 @@ resync progress line as well.
\- Adds, if run in X, display manager type to Desktop information, if present. If none, shows N/A.
Supports most known display managers, like xdm, gdm, kdm, slim, lightdm, or mdm.
.TP
.B \-xx \-w
.B \-xx \-w / \-W
\- Adds humidity and barometric pressure.
.TP
.B \-xx \-@ <11\-14>
@ -370,9 +378,9 @@ Supports most known display managers, like xdm, gdm, kdm, slim, lightdm, or mdm.
\- Adds, if run in X, shell/panel type info to Desktop information, if present. If none, shows nothing.
Supports some current desktop extras like gnome\-panel, lxde\-panel, and others. Added mainly for Mint support.
.TP
.B \-xxx \-w
\- Adds third line of information: location (city state country), weather observation time, altitude of system.
If wind chill, heat index, or dew point are available, adds a line for to hold that data as well.
.B \-xxx \-w / \-W
\- Adds location (city state country), weather observation time, altitude of system.
If wind chill, heat index, or dew point are available, shows that data as well.
.SH ADVANCED OPTIONS
.TP
@ -383,13 +391,6 @@ forums or IRC.
.B \-! 32
Turns on hostname in System line. Overrides inxi config file value (if set): B_SHOW_HOST='false'.
.TP
.B \-! location=<location_string>
With \-w, get weather 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. Must have space between -! and location=. No spaces around = sign. Use only ascii letters in city/state/country names, sorry.
Examples: \-! location=95623 OR \-! location=Boston,MA OR \-! location=45.5234,\-122.6762 OR \-! location=new+york,ny
OR \-! location=bodo,norway OR \-! location=
.SH DEBUGGING OPTIONS
.TP
.B \-%

View file

@ -1,3 +1,23 @@
=====================================================================================
Version: 1.9.7
Patch Version: 00
Script Date: May 25 2013
-----------------------------------
Changes:
-----------------------------------
New tarball, version, man page. Improved remote weather, now it uses -W, and deprecated -! location=..
That was too hard to type and too hard to remember. Also do more dyanamic reordering of weather
output, depending on how much data is present, and how many x options are used.
Added error handling for generic deprecated options, and for options that do not have the correct
syntax for OPTARG, like with -W.
This should about do it for the weather option for now unless I missed something somewhere.
-----------------------------------
-- Harald Hope - Sat, 25 May 2013 20:16:01 -0700
=====================================================================================
Version: 1.9.6
Patch Version: 00