#!/bin/sh set -e readonly QUOTES="${XDG_DATA_HOME:-$HOME/.local/share}/romir/quotes.yml" readonly QOTD="${XDG_CACHE_HOME:-$HOME/.cache}/qotd" if [ ! -f "$QUOTES" ] then dirname "$QUOTES" | xargs mkdir -p chronic wget 'https://romir.eu/mangoes.yaml' -O "$QUOTES" fi if [ ! -f "$QOTD" ] then mod=0000-00-00 else mod=`stat -c %y "$QOTD" | xargs -I{} -- date -d{} +%F` fi [ $mod != `date +%F` ] \ && yq -0 '.mangoes.[].quote.content' <"$QUOTES" \ | shuf -zn1 \ | tr '\0' '\n' >"$QOTD"