Skip to content

Commit fead19a

Browse files
Merge pull request #305 from fvincenzo/master
2 parents eac476f + 4c37751 commit fead19a

File tree

2 files changed

+2
-19
lines changed

2 files changed

+2
-19
lines changed

scripts/weather.sh

+2-14
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ fetch_weather_information()
4242
#get weather display
4343
display_weather()
4444
{
45-
fahrenheit=$1
4645
if $fahrenheit; then
4746
display_weather='&u' # for USA system
4847
else
@@ -74,24 +73,13 @@ forecast_unicode()
7473
fi
7574
}
7675

77-
export -f display_weather
78-
export -f display_location
79-
export -f forecast_unicode
80-
export -f fetch_weather_information
81-
8276
main()
8377
{
8478
# process should be cancelled when session is killed
8579
if timeout 1 bash -c "</dev/tcp/ipinfo.io/443" && timeout 1 bash -c "</dev/tcp/wttr.in/443"; then
86-
if ! weather=$(timeout 3 bash -c "display_weather $fahrenheit"); then
87-
echo "Weather Unavailable"
88-
elif ! location=$(timeout 3 bash -c display_location); then
89-
echo "Location Unavailable"
90-
else
91-
echo "${weather}${location}"
92-
fi
80+
echo "$(display_weather)$(display_location)"
9381
else
94-
echo "Network Error"
82+
echo "Weather Unavailable"
9583
fi
9684
}
9785

scripts/weather_wrapper.sh

-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ 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
1514
TIME_NOW=$(date +%s)
1615
TIME_LAST=$(cat "${LAST_EXEC_FILE}" 2>/dev/null || echo "0")
1716

@@ -23,10 +22,6 @@ main()
2322
# Run weather script here
2423
$current_dir/weather.sh $fahrenheit $location "$fixedlocation" > "${DATAFILE}"
2524
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}"
3025
fi
3126

3227
cat "${DATAFILE}"

0 commit comments

Comments
 (0)