Skip to content

Commit 66e3b0a

Browse files
committed
added timeout to the weather_wrapper.sh script
If the last data that we received was actually an error message then we instead retry the connection every 1 minute until we get a valid status. This allows for faster recovery if the last check timed up with a network error.
1 parent a3398ad commit 66e3b0a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

scripts/weather_wrapper.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ fixedlocation=$3
1111
DATAFILE=/tmp/.dracula-tmux-data
1212
LAST_EXEC_FILE="/tmp/.dracula-tmux-weather-last-exec"
1313
RUN_EACH=1200
14+
RETRY_EACH=60
1415
TIME_NOW=$(date +%s)
1516
TIME_LAST=$(cat "${LAST_EXEC_FILE}" 2>/dev/null || echo "0")
1617

@@ -22,6 +23,10 @@ main()
2223
# Run weather script here
2324
$current_dir/weather.sh $fahrenheit $location "$fixedlocation" > "${DATAFILE}"
2425
echo "${TIME_NOW}" > "${LAST_EXEC_FILE}"
26+
elif grep -q 'Unavailable\|Error' "${DATAFILE}" && [ "$(expr ${TIME_LAST} + ${RETRY_EACH})" -lt "${TIME_NOW}" ]; then
27+
# Run weather script here
28+
$current_dir/weather.sh $fahrenheit $location "$fixedlocation" > "${DATAFILE}"
29+
echo "${TIME_NOW}" > "${LAST_EXEC_FILE}"
2530
fi
2631

2732
cat "${DATAFILE}"

0 commit comments

Comments
 (0)