New backup 2025-07-11 10:15:07
This commit is contained in:
parent
da9df03584
commit
3b660b6179
3 changed files with 6 additions and 100 deletions
|
@ -19,25 +19,25 @@ update_cache_json(){
|
||||||
case "${condition_code}" in
|
case "${condition_code}" in
|
||||||
#https://openweathermap.org/weather-conditions#Weather-Condition-Codes-2
|
#https://openweathermap.org/weather-conditions#Weather-Condition-Codes-2
|
||||||
(2[0-9][0-9])
|
(2[0-9][0-9])
|
||||||
condition_icon=''
|
condition_icon=''
|
||||||
;;
|
;;
|
||||||
(3[0-9][0-9])
|
(3[0-9][0-9])
|
||||||
condition_icon=''
|
condition_icon=''
|
||||||
;;
|
;;
|
||||||
(5[0-9][0-9])
|
(5[0-9][0-9])
|
||||||
condition_icon=''
|
condition_icon=''
|
||||||
;;
|
;;
|
||||||
(6[0-9][0-9])
|
(6[0-9][0-9])
|
||||||
condition_icon=''
|
condition_icon=''
|
||||||
;;
|
;;
|
||||||
(7[0-9][0-9])
|
(7[0-9][0-9])
|
||||||
condition_icon='▒'
|
condition_icon=''
|
||||||
;;
|
;;
|
||||||
800)
|
800)
|
||||||
condition_icon=''
|
condition_icon=''
|
||||||
;;
|
;;
|
||||||
(80[0-9])
|
(80[0-9])
|
||||||
condition_icon=''
|
condition_icon=''
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
wttr_cache="${HOME}/.cache/wttr.json"
|
|
||||||
|
|
||||||
if [[ ! $(find "${wttr_cache}" -cmin -60 -print 2>/dev/null) ]]; then
|
|
||||||
if ! ping -w 15 -c 1 wttr.in;then
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
wttr_json=$(curl --silent wttr.in/Eugene?format=j1)
|
|
||||||
if [ "" != "${wttr_json}" ]; then
|
|
||||||
echo "${wttr_json}" | tee "${wttr_cache}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
condition="$(jq -r '.current_condition[0].weatherDesc[0].value' ${wttr_cache})"
|
|
||||||
condition_code="$(jq -r '.current_condition[0].weatherCode' ${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')"
|
|
||||||
|
|
||||||
case "${condition_code}" in
|
|
||||||
113)
|
|
||||||
""
|
|
||||||
;;
|
|
||||||
116|119|122|143)
|
|
||||||
condition_icon=""
|
|
||||||
;;
|
|
||||||
179|227|230)
|
|
||||||
condition_icon=""
|
|
||||||
;;
|
|
||||||
248|260)
|
|
||||||
condition_icon="▒"
|
|
||||||
;;
|
|
||||||
176|182|185|200|263|266|281|284|293|296|299|302|305|308|311)
|
|
||||||
condition_icon=""
|
|
||||||
;;
|
|
||||||
386)
|
|
||||||
condition_icon=""
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
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 icon "${condition_icon}" --arg updated "${updated}" '{condition: $condition,current_temp: $current_temp,feels_temp: $feels_temp,min_temp: $min_temp,max_temp: $max_temp,humidity: $humidity,icon: $icon,updated: $updated}'
|
|
|
@ -1,49 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
wttr_cache="${HOME}/.cache/wttr.json"
|
|
||||||
#jq -r '.current_condition[0].weatherCode' ${wttr_cache}
|
|
||||||
jq -r '.current_condition[0].weatherCode' ${wttr_cache}
|
|
||||||
condition_code="$(jq -r '.current_condition[0].weatherCode' ${wttr_cache})"
|
|
||||||
|
|
||||||
case "${condition_code}" in
|
|
||||||
113)
|
|
||||||
#Sunny
|
|
||||||
echo ""
|
|
||||||
;;
|
|
||||||
116|119|122|143)
|
|
||||||
#Partly cloudy
|
|
||||||
#Cloudy
|
|
||||||
#Overcast
|
|
||||||
#Mist
|
|
||||||
echo ""
|
|
||||||
;;
|
|
||||||
179|227|230)
|
|
||||||
#Patchy snow possible
|
|
||||||
#Blowing snow
|
|
||||||
#Blizzard
|
|
||||||
echo ""
|
|
||||||
;;
|
|
||||||
248|260)
|
|
||||||
#Fog
|
|
||||||
#Freezing fog
|
|
||||||
echo "▒"
|
|
||||||
;;
|
|
||||||
176|182|185|200|263|266|281|284|293|296|299|302|305|308|311)
|
|
||||||
#Patchy rain possible
|
|
||||||
#Patchy sleet possible
|
|
||||||
#Patchy freezing drizzle possible
|
|
||||||
#Thundery outbreaks possible
|
|
||||||
#Patchy light drizzle
|
|
||||||
#Light drizzle
|
|
||||||
#Freezing drizzle
|
|
||||||
#Heavy freezing drizzle
|
|
||||||
#Patchy light rain
|
|
||||||
#Light rain
|
|
||||||
#Moderate rain at times
|
|
||||||
#Moderate rain
|
|
||||||
#Heavy rain at times
|
|
||||||
#Heavy rain
|
|
||||||
#Light freezing rain
|
|
||||||
echo ""
|
|
||||||
;;
|
|
||||||
esac
|
|
Loading…
Add table
Reference in a new issue