From b6e55364cc22bf4685d163b1f4a316001332a9f1 Mon Sep 17 00:00:00 2001 From: Curtis Jones Date: Wed, 28 Aug 2024 10:25:41 -0400 Subject: [PATCH] fixed weather app showing "Location Unavailable" My work environment blocks outgoing ping so the weather applet has never worked. I've changed the weather script to use Linux's tcp stackt to test connection to port 443 of ipinfo.io instead of pings. --- scripts/weather.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/weather.sh b/scripts/weather.sh index 583afd63..99ee5024 100755 --- a/scripts/weather.sh +++ b/scripts/weather.sh @@ -46,7 +46,7 @@ display_weather() temperature=$(echo $weather_information | rev | cut -d ' ' -f 1 | rev) # +31°C, -3°F, etc unicode=$(forecast_unicode $weather_condition) - echo "$unicode${temperature/+/}" # remove the plus sign to the temperature + echo "$unicode ${temperature/+/}" # remove the plus sign to the temperature } forecast_unicode() @@ -69,7 +69,7 @@ forecast_unicode() main() { # process should be cancelled when session is killed - if ping -q -c 1 -W 1 ipinfo.io &>/dev/null; then + if (echo > /dev/tcp/ipinfo.io/443) >/dev/null 2>&1; then echo "$(display_weather)$(display_location)" else echo "Location Unavailable"