From 0e71af11a27631e45c0160842e4498507420eff0 Mon Sep 17 00:00:00 2001 From: stkhan Date: Fri, 31 Mar 2023 19:42:29 -0500 Subject: bar and blocks --- wm/someblocks/dwmblocks-forecast | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 wm/someblocks/dwmblocks-forecast (limited to 'wm/someblocks/dwmblocks-forecast') diff --git a/wm/someblocks/dwmblocks-forecast b/wm/someblocks/dwmblocks-forecast new file mode 100755 index 0000000..3c2482e --- /dev/null +++ b/wm/someblocks/dwmblocks-forecast @@ -0,0 +1,18 @@ +#!/bin/sh + +weatherreport="$HOME/.cache/dwmblocks_forecast" +getforecast() { curl -sf "wttr.in/" > "$weatherreport" || exit 1 ;} + +# Some very particular and terse stream manipulation. We get the maximum +# precipitation chance and the daily high and low from the downloaded file and +# display them with coresponding emojis. +showweather() { printf "%s" "$(sed '16q;d' "$weatherreport" | + grep -wo "[0-9]*%" | sort -rn | sed "s/^/☔ /g;1q" | tr -d '\n')" +sed '13q;d' "$weatherreport" | grep -o "m\\([-+]\\)*[0-9]\\+" | sed 's/+//g' | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " 🥶 " $1 "°","🌞 " $2 "°"}' ;} + +# The test if our forcecast is updated to the day. If it isn't download a new +# weather report from wttr.in with the above function. +[ "$(stat -c %y "$weatherreport" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] || + getforecast + +showweather -- cgit v1.2.3