mirror of
https://codeberg.org/frosty/dotfiles.git
synced 2024-09-19 03:37:10 -04:00
bin: delete weather
This commit is contained in:
parent
b8e3b341ff
commit
b527fcd1a6
|
@ -1,31 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
WTTR_URL="${WTTR_URL:-wttr.in}"
|
|
||||||
REPORT_FILE="${XDG_CACHE_HOME:-$HOME/.cache}/wttr-report"
|
|
||||||
UPDATE_INTERVAL_SECONDS=1800
|
|
||||||
|
|
||||||
notify() {
|
|
||||||
notify-send "${0##*/}" "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
is_report_old() {
|
|
||||||
current_time="$(date +'%s')"
|
|
||||||
report_file_time="$(date -r "$REPORT_FILE" +'%s')"
|
|
||||||
[ "$((current_time - report_file_time))" -ge "$UPDATE_INTERVAL_SECONDS" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ ! -f "$REPORT_FILE" ] || is_report_old; then
|
|
||||||
curl -s "$WTTR_URL?format=%C\n%t\n" >"$REPORT_FILE"
|
|
||||||
notify "Fetched new weather report."
|
|
||||||
fi
|
|
||||||
|
|
||||||
i=0
|
|
||||||
while IFS= read -r line; do
|
|
||||||
case "$i" in
|
|
||||||
0) conditions="${line%[[:space:]]}" ;;
|
|
||||||
1) temperature="${line#+}" ;;
|
|
||||||
esac
|
|
||||||
i=$((i + 1))
|
|
||||||
done <"$REPORT_FILE"
|
|
||||||
|
|
||||||
printf '%s (%s)\n' "$conditions" "$temperature"
|
|
Loading…
Reference in a new issue