summaryrefslogtreecommitdiff
path: root/ar/.local/bin/statusbar/sb-forecast
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2026-03-26 13:51:38 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2026-03-26 13:51:38 +0900
commitf60c21b17c0de2f0cf05f65dec23857d2947fb55 (patch)
treefb44faa2272dfd1552bc12d0b9d91fb795327c4e /ar/.local/bin/statusbar/sb-forecast
parent67a868697148fcbadadf45e638ab4b8a0b16a24e (diff)
modified statusbar/sb-clock, modified statusbar/sb-forecast
Diffstat (limited to 'ar/.local/bin/statusbar/sb-forecast')
-rwxr-xr-xar/.local/bin/statusbar/sb-forecast6
1 files changed, 4 insertions, 2 deletions
diff --git a/ar/.local/bin/statusbar/sb-forecast b/ar/.local/bin/statusbar/sb-forecast
index 061b095..6d9b086 100755
--- a/ar/.local/bin/statusbar/sb-forecast
+++ b/ar/.local/bin/statusbar/sb-forecast
@@ -6,9 +6,11 @@
# Cache location for 24 hours - stores lat,lon
locationfile="${XDG_CACHE_HOME:-${HOME}/.cache}/statusbar/location"
-if [ ! -s "$locationfile" ] || [ $(($(date +%s) - $(stat -c %Y "$locationfile" 2>/dev/null || echo 0))) -gt 86400 ]; then
+valid_latlon() { echo "$1" | grep -qE '^-?[0-9]+\.?[0-9]*,-?[0-9]+\.?[0-9]*$'; }
+if ! ([ -s "$locationfile" ] && valid_latlon "$(cat "$locationfile")" && [ $(($(date +%s) - $(stat -c %Y "$locationfile" 2>/dev/null || echo 0))) -le 86400 ]); then
mkdir -p "${XDG_CACHE_HOME:-${HOME}/.cache}/statusbar"
- curl -s http://ip-api.com/json 2>/dev/null | jq -r '[.lat, .lon] | join(",")' >"$locationfile" 2>/dev/null || true
+ loc=$(curl -s http://ip-api.com/json 2>/dev/null | jq -r 'select(.status == "success") | [.lat, .lon] | join(",")' 2>/dev/null)
+ valid_latlon "$loc" && echo "$loc" >"$locationfile"
fi
location=$(cat "$locationfile" 2>/dev/null || echo "")