X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=bin%2Ftoday;h=f9c2d289193680f400ce7b78061d5ded6c888a70;hb=afdac54142efb8663513565954adcac7dc60df2d;hp=74640e0ea89bfdf826a0189d7508053dcd8a57be;hpb=d746703ea97b59dc14ed6f80e1908a774645f19a;p=khome.git diff --git a/bin/today b/bin/today index 74640e0..f9c2d28 100755 --- a/bin/today +++ b/bin/today @@ -51,16 +51,21 @@ weather_fetch() { 2> /dev/null } +weather_file_age() { + echo $(( $(date +%s) - $(stat -c '%Y' "$FILE_WEATHER") )) +} + weather_get_or_fetch() { - weather_file_age=$(( $(date +%s) - $(stat -c '%Y' "$FILE_WEATHER") )) weather_file_age_limit=$(( 3 * 60 * 60 )) - if [[ ! -e $FILE_WEATHER || $weather_file_age -ge $weather_file_age_limit ]] + if [[ ! -e $FILE_WEATHER || weather_file_age -ge $weather_file_age_limit ]] then weather_fetch fi cat "$FILE_WEATHER" } +weather="$(weather_get_or_fetch)" + clear #LANG="$ts_lang" ncal -M $(date +%Y) LANG="$ts_lang" ncal -M @@ -77,5 +82,5 @@ echo "$ip_addresses" echo "$bar" echo '' echo "Fetched on: $(stat -c %y $FILE_WEATHER)" -echo "$(weather_get_or_fetch)" +echo "$weather" echo ''