check for cache dir before wttr

This commit is contained in:
Morgan McMillian 2021-05-10 21:51:09 -07:00
parent c45f6fbafc
commit 5b6df3bb57

View file

@ -54,18 +54,22 @@ DISPSTAT="$E$L"
# weather (https://github.com/chubin/wttr.in) # weather (https://github.com/chubin/wttr.in)
# add %l for location # add %l for location
WCACHE=~/.cache/thrrgilag/wttr if [ -d ~/.cache/thrrgilag ];
if [ ! -f $WCACHE ];
then then
WCACHE=~/.cache/thrrgilag/wttr
if [ ! -f $WCACHE ];
then
touch $WCACHE touch $WCACHE
fi fi
AGE=$(($(date +%s) - $(stat -c '%Y' "$WCACHE"))) AGE=$(($(date +%s) - $(stat -c '%Y' "$WCACHE")))
if [ $AGE -gt 1800 ] || [ ! -s $WCACHE ]; if [ $AGE -gt 1800 ] || [ ! -s $WCACHE ];
then then
curl -s en.wttr.in/?format="%l+%t+%C+%h+%w+%m" > $WCACHE curl -s en.wttr.in/?format="%l+%t+%C+%h+%w+%m" > $WCACHE
#echo "-" > $WCACHE fi
WEATHER=$(cat $WCACHE)
else
WEATHER=""
fi fi
WEATHER=$(cat $WCACHE)
# spotify # spotify
MCLASS=$(playerctl metadata --player=spotify --format '{{lc(status)}}') MCLASS=$(playerctl metadata --player=spotify --format '{{lc(status)}}')