aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/UserScripts
diff options
context:
space:
mode:
Diffstat (limited to 'config/hypr/UserScripts')
-rwxr-xr-xconfig/hypr/UserScripts/WeatherWrap.sh26
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
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage