]> piware.de Git - bin.git/commitdiff
daytime-term: Tolerate curl failures
authorMartin Pitt <martin@piware.de>
Sat, 4 Oct 2025 04:26:24 +0000 (06:26 +0200)
committerMartin Pitt <martin@piware.de>
Sat, 4 Oct 2025 04:26:24 +0000 (06:26 +0200)
Fixes failure when disconnected or on broken network.

daytime-term

index 51f9b827bc2d5fe84546bbf0146070b1a5e0dc02..c7f0c5f05f1ab6de8d3e2965a7cd6b6acd6aefef 100755 (executable)
@@ -10,7 +10,7 @@ elif [ "${1:-}" = "day" ]; then
 else
     # get daylight times at most once a day
     if [ ! -e "$DATA" ] || [ $(( `date +%s` - `stat -c %Y $DATA` )) -gt 86400 ]; then
-        curl --silent --show-error -o "$DATA" 'https://api.sunrise-sunset.org/json?lat=48.22&lng=10.54&formatted=0'
+        curl --silent --show-error --connect-timeout=5 -o "$DATA" 'https://api.sunrise-sunset.org/json?lat=48.22&lng=10.54&formatted=0' || true
     fi
     sunrise=$(jq -r .results.sunrise < ~/.cache/sunrise.json)
     sunset=$(jq -r .results.sunset < ~/.cache/sunrise.json)