summaryrefslogtreecommitdiff
path: root/.local/bin/weather
diff options
context:
space:
mode:
authorJacob McDonnell <jacob@jacobmcdonnell.com>2023-01-03 18:36:25 -0500
committerJacob McDonnell <jacob@jacobmcdonnell.com>2023-01-03 18:36:25 -0500
commitb9e00afded90f03ac18f75aa7dfc8e7f3e146348 (patch)
treec297115213f6113177b6b17743739addc16307ef /.local/bin/weather
parent09e361a7a4d76ae88520b7a89fe8d0ac3192fcba (diff)
Added some scripts
Diffstat (limited to '.local/bin/weather')
-rwxr-xr-x.local/bin/weather10
1 files changed, 10 insertions, 0 deletions
diff --git a/.local/bin/weather b/.local/bin/weather
new file mode 100755
index 0000000..000ba1b
--- /dev/null
+++ b/.local/bin/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