diff options
| author | Donald Williams <129223418+dwilliam62@users.noreply.github.com> | 2025-12-29 16:10:09 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-29 16:10:09 -0500 |
| commit | 44a9a5af345c93cb269d5d76e720a6db6fad1032 (patch) | |
| tree | 21fdfac3b47258ef240d26ce1b56349ec04c6fa6 | |
| parent | d95cd6e50ef56a399c386f4385c1471fb1ef25b5 (diff) | |
| parent | 059476451904e27694e88d21d793487b44a4442c (diff) | |
Merge branch 'development' into patch-2
| -rwxr-xr-x | config/hypr/UserScripts/WeatherWrap.sh | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/config/hypr/UserScripts/WeatherWrap.sh b/config/hypr/UserScripts/WeatherWrap.sh index 10c125dc..5b266930 100755 --- a/config/hypr/UserScripts/WeatherWrap.sh +++ b/config/hypr/UserScripts/WeatherWrap.sh @@ -6,6 +6,30 @@ SCRIPT_DIR="$(dirname "$0")" PY_SCRIPT="$SCRIPT_DIR/Weather.py" BASH_FALLBACK="$SCRIPT_DIR/Weather.sh" +# Function to check network connectivity +check_network() { + # Try multiple methods to check network + if ping -c1 -W2 8.8.8.8 >/dev/null 2>&1; then + return 0 + fi + + if ping -c1 -W2 1.1.1.1 >/dev/null 2>&1; then + return 0 + fi + + if curl -s --connect-timeout 3 "https://ipinfo.io" >/dev/null 2>&1; then + return 0 + fi + + return 1 +} + +# If no network, return offline status immediately +if ! check_network; then + echo '{"text":"", "alt":"Offline", "tooltip":"No network connection"}' + exit 0 +fi + run_fallback() { if [ -f "$BASH_FALLBACK" ]; then # Invoke via bash to avoid requiring +x and ensure consistent shell @@ -30,4 +54,4 @@ else echo "python3 not found in PATH — falling back to Weather.sh" >&2 run_fallback "$@" exit $? -fi
\ No newline at end of file +fi |
