ansiweather

Weather in terminal, with ANSI colors and Unicode symbols
Log | Files | Refs | README | LICENSE

commit 8eed6ac77ebeb0380274aabb7e9c4118e4c18f4f
parent 727eb2b062caae14363290b0eeb2723dcc450010
Author: royhodgman <royhodgman@yahoo.com>
Date:   Thu,  2 Jan 2014 21:41:35 -0500

added sunrise and sunset data to the display

Diffstat:
Mansiweather | 34++++++++++++++++++++++++++++++++--
Mansiweatherrc.example | 2++
2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/ansiweather b/ansiweather @@ -119,7 +119,8 @@ greeting_text=$(get_config "greeting" || echo "Current weather in") wind_text=$(get_config "wind" || echo "Wind") humidity_text=$(get_config "humidity" || echo "Humidity") pressure_text=$(get_config "pressure" || echo "Pressure") - +sunrise_text=$(get_config "sunrise" || echo "Sunrise") +sunset_text=$(get_config "sunset" || echo "Sunset") ###[ Unicode Symbols for icons ]############################################### @@ -218,6 +219,35 @@ fi +###[ Process Sunrise and Sunset data ]######################################### + +function epoch_to_time { + unamestr=$(uname) + if date -j -r $1 +"%r" > /dev/null 2>&1; then + # BSD + ret=$(date -j -r $1 +"%b %d %r") + else + # GNU + ret=$(date -d @$1 +"%b %d %r") + fi + echo $ret +} + +if [ $forecast = 0 ] +then + if [ -n "$sunrise" ] + then + sunrise_time=$(epoch_to_time $sunrise) + fi + + if [ -n "$sunset" ] + then + sunset_time=$(epoch_to_time $sunset) + fi +fi + + + ###[ Set the period ]########################################################## now=$(date +%s) @@ -315,5 +345,5 @@ then output="$output\033[0m" echo -e "$output" else - echo -e "$background$text $greeting_text $city $delimiter$data $temperature $scale $icon$dashes$text $wind_text $delimiter$data $wind $speed_unit $direction $dashes$text $humidity_text $delimiter$data $humidity % $dashes$text $pressure_text $delimiter$data $pressure $pressure_unit \033[0m" + echo -e "$background$text $greeting_text $city $delimiter$data $temperature $scale $icon$dashes$text $wind_text $delimiter$data $wind $speed_unit $direction $dashes$text $humidity_text $delimiter$data $humidity % $dashes$text $pressure_text $delimiter$data $pressure $pressure_unit $dashes$text $sunrise_text $delimiter$data $sunrise_time $dashes$text $sunset_text $delimiter$data $sunset_time\033[0m" fi diff --git a/ansiweatherrc.example b/ansiweatherrc.example @@ -16,6 +16,8 @@ greeting_text:Current weather in wind_text:Wind humidity_text:Humidity pressure_text:Pressure +sunrise_text:Sunrise +sunset_text:Sunset # Icons sun:\033[33;1m\xe2\x98\x80