From 87a3773df52e73f755772f2cb109734e9c2158c9 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Mon, 28 Aug 2023 00:42:40 +0300 Subject: qotd: Add quotes of the day --- .bashrc | 2 ++ .local/bin/qotd | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100755 .local/bin/qotd diff --git a/.bashrc b/.bashrc index c805527..bee389a 100644 --- a/.bashrc +++ b/.bashrc @@ -80,3 +80,5 @@ alias sv=sudoedit alias v="$VISUAL" PS1='\[\e[96;1m\]\u \[\e[39m\]\W \[\e[96m\]〉\[\e[0m\]' + +sed '1s/^/‘/; $s/$/’/' "$XDG_CACHE_HOME/qotd" | wtos diff --git a/.local/bin/qotd b/.local/bin/qotd new file mode 100755 index 0000000..3648072 --- /dev/null +++ b/.local/bin/qotd @@ -0,0 +1,24 @@ +#!/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" -- cgit v1.2.3