dotfiles/bin/weather_cached

13 lines
275 B
Plaintext
Raw Normal View History

2020-08-02 00:06:16 +00:00
#!/bin/sh
CACHE_FILE="$HOME/.tmux/.weather_cache"
CACHE_TIME=$(stat -f %m $CACHE_FILE)
NOW_TIME=$(date +%s)
TIME_PASSED=$((NOW_TIME-CACHE_TIME))
if [[ "$TIME_PASSED" -gt "1200" ]]
then
2020-12-04 16:03:44 +00:00
curl -m 2 -s wttr.in/$WEATHER_CITY\?format\="%c%t" > $CACHE_FILE
2020-08-02 00:06:16 +00:00
fi
cat $CACHE_FILE