Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The weather plugin is broken: revert the latest changes to make it functional again #305

Merged
merged 2 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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