diff options
| author | Prabin Panta <pantaprabin30@gmail.com> | 2025-10-28 17:21:02 +0545 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-28 17:21:02 +0545 |
| commit | 950e776c81d3faec64374a238b86ca61b7770cfe (patch) | |
| tree | 49e168f7129a9a242fe9f65cc1358644baf6377c /config/hypr/UserScripts/weatherWrap.sh | |
| parent | 163bce40d9612bbc364b8c6aea0892230e39bee7 (diff) | |
| parent | 2c32d1cc6ca9397db2db94bb50ad5238fa75d0c9 (diff) | |
Merge pull request #9 from prabinpanta0/development-weather
Development weather
Diffstat (limited to 'config/hypr/UserScripts/weatherWrap.sh')
| -rwxr-xr-x | config/hypr/UserScripts/weatherWrap.sh | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/config/hypr/UserScripts/weatherWrap.sh b/config/hypr/UserScripts/weatherWrap.sh new file mode 100755 index 00000000..4c9a16dc --- /dev/null +++ b/config/hypr/UserScripts/weatherWrap.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## +# Weather entrypoint: prefer Python (Open‑Meteo), fallback to legacy Bash (wttr.in) + +SCRIPT_DIR="$(dirname "$0")" +PY_SCRIPT="$SCRIPT_DIR/Weather.py" +BASH_FALLBACK="$SCRIPT_DIR/Weather.sh" + +run_fallback() { + if [ -f "$BASH_FALLBACK" ]; then + # Invoke via bash to avoid requiring +x and ensure consistent shell + bash "$BASH_FALLBACK" "$@" + return $? + else + echo "Weather fallback not found: $BASH_FALLBACK" >&2 + return 127 + fi +} + +if command -v python3 >/dev/null 2>&1; then + python3 "$PY_SCRIPT" "$@" + exit_code=$? + if [ "$exit_code" -eq 0 ]; then + exit 0 + fi + echo "Weather.py failed with code $exit_code — falling back to Weather.sh" >&2 + run_fallback "$@" + exit $? +else + echo "python3 not found in PATH — falling back to Weather.sh" >&2 + run_fallback "$@" + exit $? +fi
\ No newline at end of file |
