summaryrefslogtreecommitdiff
path: root/scripts/weather
diff options
context:
space:
mode:
authorJacob McDonnell <jacob@jacobmcdonnell.com>2024-12-05 13:49:22 -0500
committerJacob McDonnell <jacob@jacobmcdonnell.com>2024-12-05 13:49:22 -0500
commitf8d09c5cfd6d1d9595b64547dc9d29c63e40c5f2 (patch)
tree0dd9cfa47cfa0bd4d57d7789439cc86afbbdfa85 /scripts/weather
parent29b1c791f6e319cdab828cee5f491ca1c38e41d1 (diff)
Moved .local/bin to scripts
Diffstat (limited to 'scripts/weather')
-rwxr-xr-xscripts/weather10
1 files changed, 10 insertions, 0 deletions
diff --git a/scripts/weather b/scripts/weather
new file mode 100755
index 0000000..664b0b1
--- /dev/null
+++ b/scripts/weather
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+getforecast() { ping -q -c 1 1.1.1.1 >/dev/null || exit 1
+curl -sf "wttr.in/Ocean+City" > "$HOME/.cache/weatherreport" || exit 1 ;}
+
+showweather() { printf "%s" "$(sed '16q;d' "$HOME/.cache/weatherreport" | grep -wo "[0-9]*%" | sort -n | sed -e '$!d' | sed -e "s/^/☔ /g" | tr -d '\n')"
+sed '13q;d' "$HOME/.cache/weatherreport" | grep -o "m\\(-+\\)*[0-9]\\+" | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " ❄",$1 "°","🌞",$2 "°"}' ;}
+
+[ "$(stat -c %y "$HOME/.cache/weatherreport" 2>/dev/null | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] && getforecast
+showweather