swaydots

my dotfiles
git clone https://git.awy.one/swaydots.git
Log | Files | Refs | README | LICENSE

commit 8cf6aeb5f996bfb5121651e07af80741980702c8
parent fe4c41a1fac37080cb75c4505a28c3697f3f1006
Author: awy <awy@awy.one>
Date:   Tue, 13 May 2025 18:51:00 +0300

weather forecast every 30 mins

Diffstat:
M.config/i3blocks/config | 2+-
M.local/bin/statusbar/sb-forecast | 10+++++++---
2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/.config/i3blocks/config b/.config/i3blocks/config @@ -35,7 +35,7 @@ signal=14 [weather] command=sb-forecast -interval=3600 +interval=1800 signal=5 [mail] diff --git a/.local/bin/statusbar/sb-forecast b/.local/bin/statusbar/sb-forecast @@ -11,10 +11,14 @@ getforecast() { { grep -q -m1 '^up$' /sys/class/net/w*/operstate || grep -q -m1 curl -sf "$url/$LOCATION" --output "$weatherreport" && touch "$weatherreport" } -# Forecast should be updated only once a day. checkforecast() { - [ "$(stat -c %y "$weatherreport" 2>/dev/null | - cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] + [ -f "$weatherreport" ] || return 1 # file doesn't exist -> needs update + + last_fetch=$(stat -c %Y "$weatherreport") + now=$(date +%s) + max_age=$((30 * 60)) # 30 minutes in seconds + + [ $((now - last_fetch)) -lt $max_age ] } getprecipchance() {