Skip to content

Commit

Permalink
Merge pull request #305 from fvincenzo/master
Browse files Browse the repository at this point in the history
  • Loading branch information
ethancedwards8 authored Oct 19, 2024
2 parents eac476f + 4c37751 commit fead19a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
16 changes: 2 additions & 14 deletions scripts/weather.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ fetch_weather_information()
#get weather display
display_weather()
{
fahrenheit=$1
if $fahrenheit; then
display_weather='&u' # for USA system
else
Expand Down Expand Up @@ -74,24 +73,13 @@ forecast_unicode()
fi
}

export -f display_weather
export -f display_location
export -f forecast_unicode
export -f fetch_weather_information

main()
{
# process should be cancelled when session is killed
if timeout 1 bash -c "</dev/tcp/ipinfo.io/443" && timeout 1 bash -c "</dev/tcp/wttr.in/443"; then
if ! weather=$(timeout 3 bash -c "display_weather $fahrenheit"); then
echo "Weather Unavailable"
elif ! location=$(timeout 3 bash -c display_location); then
echo "Location Unavailable"
else
echo "${weather}${location}"
fi
echo "$(display_weather)$(display_location)"
else
echo "Network Error"
echo "Weather Unavailable"
fi
}

Expand Down
5 changes: 0 additions & 5 deletions scripts/weather_wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ fixedlocation=$3
DATAFILE=/tmp/.dracula-tmux-data
LAST_EXEC_FILE="/tmp/.dracula-tmux-weather-last-exec"
RUN_EACH=1200
RETRY_EACH=60
TIME_NOW=$(date +%s)
TIME_LAST=$(cat "${LAST_EXEC_FILE}" 2>/dev/null || echo "0")

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

cat "${DATAFILE}"
Expand Down

0 comments on commit fead19a

Please sign in to comment.