Skip to content

Commit

Permalink
weather.sh: added timeouts & checking for 'wttr.in'
Browse files Browse the repository at this point in the history
Still using BASH's builtin TCP connections for testing. Added the
timeout command so that the status bar doesn't have "NOT READY". Also
addded a check for 'wttr.in' port 443 as that site is used to get the
actual weather information.
  • Loading branch information
ikubetoomuzik committed Sep 3, 2024
1 parent b6e5536 commit 3d388ad
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/weather.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ forecast_unicode()
main()
{
# process should be cancelled when session is killed
if (echo > /dev/tcp/ipinfo.io/443) >/dev/null 2>&1; then
if timeout 1 bash -c "</dev/tcp/ipinfo.io/443" && timeout 1 bash -c "</dev/tcp/wttr.in/443"; then
echo "$(display_weather)$(display_location)"
else
echo "Location Unavailable"
echo "Weather Unavailable"
fi
}

Expand Down

0 comments on commit 3d388ad

Please sign in to comment.