From 18f2b551798628745d5b15330efc2fa49039c20e Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Sat, 24 Feb 2024 14:08:10 -0500 Subject: [PATCH] Switch to wttr.in for temperature, also include conditions. --- README.md | 1 - src/talking-clock | 22 ++++++++-------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index e7e36ad..0e632a0 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,6 @@ ogg123 -q or paplay -c --nochime Turn off chimes. --k --key Your weatherstack.com api key. You can get one for free from weatherstack.com -n --nospeak turn off spoken time. -s --soundpack Set path to soundpack. Sound packs should be in ogg format and contain 1.ogg, 2.ogg, ... 11.ogg, 12.ogg and 15.ogg, 30.ogg, and 45.ogg for the quarter-hour chimes. -v --voice Select voice. Default is espeak other options are diff --git a/src/talking-clock b/src/talking-clock index 786a4cd..1a5f4fe 100755 --- a/src/talking-clock +++ b/src/talking-clock @@ -15,7 +15,6 @@ half-hour, 4 every quarter, and anything else will delete your existing settings -a --audio Command for playing sound. The default is play -q provided from the sox package. -c --nochime Turn off chimes. -f --format: 12 or 24 hour format. Default is 12 hour time. --k --key: weatherstack.com api key. This is required for temperature and forecast. You can get a key for free. -n --nospeak turn off spoken time. -s --soundpack Set path to soundpack. Sound packs should be in ogg format and contain 1.ogg, 2.ogg, ... 11.ogg, 12.ogg and 15, 30, and 45.oggfor the quarter-hour chimes. @@ -306,10 +305,6 @@ while [ $# -gt 0 ] ; do exit 1 fi ;; - "-k" | "--key") - shift - key="$1" - ;; "-n" | "--nospeak") speakTime="false" ;; @@ -359,15 +354,14 @@ if [ "$speakTime" == "true" ] ; then timeString="${timeString} $(number_to_text $minute)" fi fi - #Add temperature if key is set - if [ -n "$key" ] ; then - temperature="$(curl -s "http://api.weatherstack.com/current?access_key=$key&query=${zipcode:-fetch:ip}&units=${units:-f}" | jq -r '.current.temperature')" - if [ -n "$temperature" ] ; then - if [ "$format" = "24" ]; then - timeString="$timeString and $(number_to_text $temperature) degrees." - else - timeString="$timeString $(number_to_text $temperature) degrees." - fi + #Add temperature if zipcode is set + if [ -n "$zipcode" ] ; then + temperature="$(curl -s "https://wttr.in/${zipcode}?format=%t%20degrees%20and%20%C")" + temp="${temperature//[^-[:digit:]]/}" + temperature="${temp} ${temperature#* }" + temperature="${temperature/-/Negative }" + if [ "${#temperature}" -ge 3 ] ; then + timeString="$timeString. It is currently $temperature." fi fi case "$voice" in