#!/bin/bash wttr_cache="${HOME}/.cache/wttr.json" if [[ ! $(find "${wttr_cache}" -cmin -60 -print 2>/dev/null) ]]; then # echo "File ${wttr_cache} exists and is younger than 60min" #else # echo "File ${wttr_cache} does not exists or is younger than 60min" curl --silent wttr.in/Eugene?format=j1 > "${wttr_cache}" fi #cat "${wttr_cache}" condition="$(jq -r '.current_condition[0].weatherDesc[0].value' ${wttr_cache})" current_temp="$(jq -r '.current_condition[0].temp_F' ${wttr_cache})" feels_temp="$(jq -r '.current_condition[0].FeelsLikeF' ${wttr_cache})" min_temp="$(jq -r '.weather[0].mintempF' ${wttr_cache})" max_temp="$(jq -r '.weather[0].maxtempF' ${wttr_cache})" humidity="$(jq -r '.current_condition[0].humidity' ${wttr_cache})" updated="$(date -r ${wttr_cache} '+%Y-%m-%d, %H:%M')" jq -n --arg condition "${condition}" --arg current_temp "${current_temp}" --arg feels_temp "${feels_temp}" --arg min_temp "${min_temp}" --arg max_temp "${max_temp}" --arg humidity "${humidity}" --arg updated "${updated}" '{condition: $condition,current_temp: $current_temp,feels_temp: $feels_temp,min_temp: $min_temp,max_temp: $max_temp,humidity: $humidity,updated: $updated}'