blob: 7bf6e034c3cd53509a33fc7e9ec007179b7921f6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#!/usr/local/bin/andy
func older_than_today file {
if test ! -f $file {
set mod 0000-00-00
} else {
set mod `stat -c %y $file | xargs -I{} -- date -d{} +%F
}
test $mod != `date +%F
}
set QUOTES $XDG_DATA_HOME/romir/quotes.yml
set QOTD $XDG_CACHE_HOME/qotd
if older_than_today $QUOTES {
mkdir -p `dirname $QUOTES
chronic wget 'https://romir.eu/mangoes.yaml' -O $QUOTES
}
older_than_today $QOTD
&& yq -0 '.mangoes.[].quote.content' <$QUOTES
| shuf -zn1
| tr '\0' '\n' >$QOTD
|