From 5b6df3bb570644aa026d01f5cc7b696b27ac03c7 Mon Sep 17 00:00:00 2001 From: Morgan McMillian Date: Mon, 10 May 2021 21:51:09 -0700 Subject: [PATCH] check for cache dir before wttr --- bin/statusbar | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/bin/statusbar b/bin/statusbar index 4182316..c22fe3b 100755 --- a/bin/statusbar +++ b/bin/statusbar @@ -54,18 +54,22 @@ DISPSTAT="$E$L" # weather (https://github.com/chubin/wttr.in) # add %l for location -WCACHE=~/.cache/thrrgilag/wttr -if [ ! -f $WCACHE ]; +if [ -d ~/.cache/thrrgilag ]; then - touch $WCACHE + WCACHE=~/.cache/thrrgilag/wttr + if [ ! -f $WCACHE ]; + then + touch $WCACHE + fi + AGE=$(($(date +%s) - $(stat -c '%Y' "$WCACHE"))) + if [ $AGE -gt 1800 ] || [ ! -s $WCACHE ]; + then + curl -s en.wttr.in/?format="%l+%t+%C+%h+%w+%m" > $WCACHE + fi + WEATHER=$(cat $WCACHE) +else + WEATHER="" fi -AGE=$(($(date +%s) - $(stat -c '%Y' "$WCACHE"))) -if [ $AGE -gt 1800 ] || [ ! -s $WCACHE ]; -then - curl -s en.wttr.in/?format="%l+%t+%C+%h+%w+%m" > $WCACHE - #echo "-" > $WCACHE -fi -WEATHER=$(cat $WCACHE) # spotify MCLASS=$(playerctl metadata --player=spotify --format '{{lc(status)}}')