mirror of
https://github.com/smxi/inxi.git
synced 2024-11-16 08:11:39 +00:00
New version, new man. A few more modifications to weather.
Fixes: 1. In case with zero wind speed, it now shows zero, not N/A, as expected. Enhancements: 1. Depending on weather source used: * Shows precipitation, not rain/snow. * Adds Sunrise/sunset (most sources do not have this)
This commit is contained in:
parent
a2256de3df
commit
1f037020e3
65
inxi
65
inxi
|
@ -31,8 +31,8 @@ use POSIX qw(uname strftime ttyname);
|
|||
|
||||
## INXI INFO ##
|
||||
my $self_name='inxi';
|
||||
my $self_version='3.0.31';
|
||||
my $self_date='2019-02-06';
|
||||
my $self_version='3.0.32';
|
||||
my $self_date='2019-02-07';
|
||||
my $self_patch='00';
|
||||
## END INXI INFO ##
|
||||
|
||||
|
@ -4557,8 +4557,7 @@ sub show_options {
|
|||
$self_name. Use only ASCII characters, replace spaces in city/state/country
|
||||
names with '+'. Example:^$self_name^-W^new+york,ny"],
|
||||
['1', '', '--weather-source', "[0-9] Change weather data source. 0 uses
|
||||
a legacy source internally. 1-3 use remote smxi sources. 4-9 may be added
|
||||
in the future. See man."],
|
||||
a legacy source internally. 1-3 generally active, 4-9 check. See man."],
|
||||
['1', '', '--weather-unit', "Set weather units to metric (m), imperial (i),
|
||||
metric/imperial (mi), or imperial/metric (im)."],
|
||||
);
|
||||
|
@ -4634,8 +4633,8 @@ sub show_options {
|
|||
);
|
||||
push @data, @rows;
|
||||
if ( $b_weather ){
|
||||
@rows = (['2', '-w -W', '', "Snow, rain (last observed hour), cloud cover,
|
||||
wind chill, dew point, heat index, if available." ]);
|
||||
@rows = (['2', '-w -W', '', "Snow, rain, precipitation, (last observed hour),
|
||||
cloud cover, wind chill, dew point, heat index, if available." ]);
|
||||
push @data, @rows;
|
||||
}
|
||||
@rows = (
|
||||
|
@ -4664,7 +4663,7 @@ sub show_options {
|
|||
push @data, @rows;
|
||||
if ( $b_weather ){
|
||||
@rows = (['2', '-w -W', '', "Location (uses -z/irc filter), weather observation
|
||||
time, altitude, if available." ] );
|
||||
time, altitude, sunrise/sunset, if available." ] );
|
||||
push @data, @rows;
|
||||
}
|
||||
@rows = (
|
||||
|
@ -15411,6 +15410,10 @@ sub create_output {
|
|||
if (defined $weather{'cloud-cover'}){
|
||||
$rows[0]{main::key($num++,'Cloud Cover')} = $weather{'cloud-cover'} . '%';
|
||||
}
|
||||
if ($weather{'precip-1h-mm'} && defined $weather{'precip-1h-in'} ){
|
||||
$value = unit_output('',$weather{'precip-1h-mm'},'mm',$weather{'precip-1h-in'},'in');
|
||||
$rows[0]{main::key($num++,'Precipitation')} = $value;
|
||||
}
|
||||
if ($weather{'rain-1h-mm'} && defined $weather{'rain-1h-in'} ){
|
||||
$value = unit_output('',$weather{'rain-1h-mm'},'mm',$weather{'rain-1h-in'},'in');
|
||||
$rows[0]{main::key($num++,'Rain')} = $value;
|
||||
|
@ -15451,6 +15454,12 @@ sub create_output {
|
|||
if ($extra > 2){
|
||||
$weather{'observation-time-local'} = 'N/A' if !$weather{'observation-time-local'};
|
||||
$rows[0]{main::key($num++,'Observation Time')} = $weather{'observation-time-local'};
|
||||
if ($weather{'sunrise'}){
|
||||
$rows[0]{main::key($num++,'Sunrise')} = $weather{'sunrise'};
|
||||
}
|
||||
if ($weather{'sunset'}){
|
||||
$rows[0]{main::key($num++,'Sunset')} = $weather{'sunset'};
|
||||
}
|
||||
}
|
||||
if ($weather{'api-source'}){
|
||||
$rows[0]{main::key($num++,'Source')} = $weather{'api-source'};
|
||||
|
@ -15516,21 +15525,21 @@ sub wind_output {
|
|||
$gust_mph = undef if $gust_mph && $mph && $mph eq $gust_mph;
|
||||
$gust_ms = undef if $gust_ms && $ms && $ms eq $gust_ms;
|
||||
# calculate and round, order matters so that rounding only happens after math done
|
||||
$ms = 0.44704 * $mph if $mph && !$ms;
|
||||
$mph = $ms * 2.23694 if $ms && !$mph;
|
||||
$kmh = sprintf("%.0f", 18 * $ms / 5) if $ms;
|
||||
$ms = sprintf("%.1f", $ms ) if $ms; # very low mph speeds yield 0, which is wrong
|
||||
$mph = sprintf("%.0f", $mph) if $mph;
|
||||
$ms = 0.44704 * $mph if defined $mph && !defined $ms;
|
||||
$mph = $ms * 2.23694 if defined $ms && !defined $mph;
|
||||
$kmh = sprintf("%.0f", 18 * $ms / 5) if defined $ms;
|
||||
$ms = sprintf("%.1f", $ms ) if defined $ms; # very low mph speeds yield 0, which is wrong
|
||||
$mph = sprintf("%.0f", $mph) if defined $mph;
|
||||
$gust_ms = 0.44704 * $gust_mph if $gust_mph && !$gust_ms;
|
||||
$gust_kmh = 18 * $gust_ms / 5 if $gust_ms;
|
||||
$gust_mph = $gust_ms * 2.23694 if $gust_ms && !$gust_mph;
|
||||
$gust_mph = sprintf("%.0f", $gust_mph) if $gust_mph;
|
||||
$gust_kmh = sprintf("%.0f", $gust_kmh) if $gust_kmh;
|
||||
$gust_ms = sprintf("%.0f", $gust_ms ) if $gust_ms;
|
||||
if (!$mph && $primary){
|
||||
if (!defined $mph && $primary){
|
||||
$result = $primary;
|
||||
}
|
||||
elsif ($mph && $direction ){
|
||||
elsif (defined $mph && defined $direction ){
|
||||
if ( $weather_unit eq 'mi' ){
|
||||
$result = "from $direction at $ms $m_unit ($kmh $km_unit, $mph $i_unit)";
|
||||
}
|
||||
|
@ -15654,6 +15663,12 @@ sub get_weather {
|
|||
$weather{'observation-time-local'} = $working[1];
|
||||
$weather{'observation-time-local'} =~ s/Last Updated on //;
|
||||
}
|
||||
elsif ( $working[0] eq 'precip_mm' ){
|
||||
$weather{'precip-1h-mm'} = $working[1];
|
||||
}
|
||||
elsif ( $working[0] eq 'precip_in' ){
|
||||
$weather{'precip-1h-in'} = $working[1];
|
||||
}
|
||||
elsif ( $working[0] eq 'pressure_string' ){
|
||||
$weather{'pressure'} = $working[1];
|
||||
}
|
||||
|
@ -15678,6 +15693,28 @@ sub get_weather {
|
|||
elsif ( $working[0] eq 'state_name' ){
|
||||
$weather{'state'} = $working[1];
|
||||
}
|
||||
elsif ( $working[0] eq 'sunrise' ){
|
||||
if ($working[1]){
|
||||
if ($working[1] !~ /^[0-9]+$/){
|
||||
$weather{'sunrise'} = $working[1];
|
||||
}
|
||||
# trying to figure out remote time from UTC is too hard
|
||||
elsif (!$show{'weather-location'}){
|
||||
$weather{'sunrise'} = POSIX::strftime "%T", localtime($working[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
elsif ( $working[0] eq 'sunset' ){
|
||||
if ($working[1]){
|
||||
if ($working[1] !~ /^[0-9]+$/){
|
||||
$weather{'sunset'} = $working[1];
|
||||
}
|
||||
# trying to figure out remote time from UTC is too hard
|
||||
elsif (!$show{'weather-location'}){
|
||||
$weather{'sunset'} = POSIX::strftime "%T", localtime($working[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
elsif ( $working[0] eq 'temperature_string' ){
|
||||
$weather{'temp'} = $working[1];
|
||||
$working[1] =~ /^([0-9\.]+)\sF\s\(([0-9\.]+)\sC\)/;
|
||||
|
|
28
inxi.1
28
inxi.1
|
@ -1,4 +1,4 @@
|
|||
.TH INXI 1 "2019\-02\-06" inxi "inxi manual"
|
||||
.TH INXI 1 "2019\-02\-07" inxi "inxi manual"
|
||||
.SH NAME
|
||||
inxi \- Command line system information script for console and IRC
|
||||
.SH SYNOPSIS
|
||||
|
@ -467,24 +467,24 @@ Please note that your distribution's maintainer may chose to disable this featur
|
|||
Get weather/time for an alternate location. Accepts postal/zip code[, country],
|
||||
city,state pair, or latitude,longitude. Note: city/country/state names must not
|
||||
contain spaces. Replace spaces with '\fB+\fR' sign. Don't place spaces around
|
||||
any commas. Postal code is not reliable except for North America.
|
||||
any commas. Postal code is not reliable except for North America and maybe the UK.
|
||||
Try postal codes with and without country code added.
|
||||
|
||||
Use only ASCII letters in city/state/country names.
|
||||
|
||||
Examples: \fB\-W 95623,usa\fR OR \fB\-W Boston,MA\fR OR
|
||||
Examples: \fB\-W 95623,us\fR OR \fB\-W Boston,MA\fR OR
|
||||
\fB\-W 45.5234,\-122.6762\fR OR \fB\-W new+york,ny\fR OR \fB\-W bodo,norway\fR.
|
||||
.TP
|
||||
.B \-\-weather\-source\fR, \fB\-\-ws <unit>\fR
|
||||
[\fB0\-9\fR] Switches weather data source. 0 uses a legacy source which may vanish
|
||||
any day. \fB1\-9\fR use different sources from a remote API. \fB1\fR is the same as \fB0 currently.
|
||||
\fB2\fR has less data than \fB1\fR or \fB3\fR, and may not support city / country names with spaces
|
||||
(even if you use the \fB+\fR sign instead of space). \fB3\fR offers pretty good data, but
|
||||
may not have all small city names for \fB\-W\fR. \fB4\-9\fR may be added at a future
|
||||
point, but are not currently supported.
|
||||
any day. \fB1\-9\fR use different remote sources. \fB2\fR may not support city /
|
||||
country names with spaces (even if you use the \fB+\fR sign instead of space).
|
||||
\fB3\fR offers pretty good data, but may not have all small city names for
|
||||
\fB\-W\fR.
|
||||
|
||||
Note that the actual remote sources may change without notice, but that will have
|
||||
no real impact on inxi. Also, additional options may be added in the future, between
|
||||
0 and 9.
|
||||
More data sources will be added as time permits, so try each one and
|
||||
see which you prefer. If you get unsupported source message, it means that number
|
||||
has not been implemented.
|
||||
.TP
|
||||
.B \-\-weather\-unit <unit>\fR
|
||||
[\fBm\fR|\fBi\fR|\fBmi\fR|\fBim\fR] Sets weather units to metric (\fBm\fR), imperial (\fBi\fR),
|
||||
|
@ -764,8 +764,8 @@ if \fBps\fR tests fail to find data.
|
|||
.B \-xx \-w\fR,\fB \-W\fR
|
||||
\- Adds wind chill, heat index, and dew point, if available.
|
||||
|
||||
\- Adds cloud cover, rain, snow (amount in previous hour to observation time),
|
||||
if available.
|
||||
\- Adds cloud cover, rain, snow, or precipitation (amount in previous hour
|
||||
to observation time), if available.
|
||||
.TP
|
||||
.B \-xxx \-A\fR
|
||||
\- Adds, if present, serial number.
|
||||
|
@ -845,7 +845,7 @@ lxpanel, xfce4\-panel, lxqt\-panel, tint2, cairo-dock, trayer, and many others.
|
|||
.TP
|
||||
.B \-xxx \-w\fR,\fB \-W\fR
|
||||
\- Adds location (city state country), observation altitude (if available),
|
||||
weather observation time (if available).
|
||||
weather observation time (if available), sunset/sunrise (if available).
|
||||
|
||||
.SH ADMIN EXTRA DATA OPTIONS
|
||||
These options are triggered with \fB\-\-admin\fR or \fB\-a\fR. Admin options are
|
||||
|
|
|
@ -1,3 +1,23 @@
|
|||
=====================================================================================
|
||||
Version: 3.0.32
|
||||
Patch: 00
|
||||
Date: 2019-02-07
|
||||
-----------------------------------
|
||||
Changes:
|
||||
-----------------------------------
|
||||
New version, new man. A few more modifications to weather.
|
||||
|
||||
Fixes:
|
||||
1. In case with zero wind speed, it now shows zero, not N/A, as expected.
|
||||
|
||||
Enhancements:
|
||||
1. Depending on weather source used:
|
||||
* Shows precipitation, not rain/snow.
|
||||
* Adds Sunrise/sunset (most sources do not have this)
|
||||
|
||||
-----------------------------------
|
||||
-- Harald Hope - Thu, 07 Feb 2019 20:50:18 -0800
|
||||
|
||||
=====================================================================================
|
||||
Version: 3.0.31
|
||||
Patch: 00
|
||||
|
|
Loading…
Reference in a new issue