From 02e4686ccd7c95c6df855be61496c75c92b11396 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Wed, 6 Dec 2023 01:30:57 +0100 Subject: scripts: Move many scripts from sh to andy --- .local/bin/qotd | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) (limited to '.local/bin/qotd') diff --git a/.local/bin/qotd b/.local/bin/qotd index fed3297..7bf6e03 100755 --- a/.local/bin/qotd +++ b/.local/bin/qotd @@ -1,30 +1,23 @@ -#!/bin/sh +#!/usr/local/bin/andy -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 $? +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 } -readonly QUOTES="${XDG_DATA_HOME:-$HOME/.local/share}/romir/quotes.yml" -readonly QOTD="${XDG_CACHE_HOME:-$HOME/.cache}/qotd" +set QUOTES $XDG_DATA_HOME/romir/quotes.yml +set QOTD $XDG_CACHE_HOME/qotd -if older_than_today "$QUOTES" -then - dirname "$QUOTES" | xargs mkdir -p - chronic wget 'https://romir.eu/mangoes.yaml' -O "$QUOTES" -fi +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" +older_than_today $QOTD +&& yq -0 '.mangoes.[].quote.content' <$QUOTES +| shuf -zn1 +| tr '\0' '\n' >$QOTD -- cgit v1.2.3