blob: fed32979000273bf1fcf681e1ad7f418b0a8d023 (
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
24
25
26
27
28
29
30
|
#!/bin/sh
set -e
older_than_today()
{
if [ ! -f "$1" ]
then
mod=0000-00-00
else
mod=`stat -c %y "$1" | xargs -I{} -- date -d{} +%F`
fi
[ $mod != `date +%F` ]
return $?
}
readonly QUOTES="${XDG_DATA_HOME:-$HOME/.local/share}/romir/quotes.yml"
readonly QOTD="${XDG_CACHE_HOME:-$HOME/.cache}/qotd"
if older_than_today "$QUOTES"
then
dirname "$QUOTES" | xargs mkdir -p
chronic wget 'https://romir.eu/mangoes.yaml' -O "$QUOTES"
fi
older_than_today "$QOTD" \
&& yq -0 '.mangoes.[].quote.content' <"$QUOTES" \
| shuf -zn1 \
| tr '\0' '\n' >"$QOTD"
|